Reply To: Pipeline and non-pipelined input?
OK. Took me some time from home to further explain my problem and maybe I have found some info for myself.If I use this command:$myVar = Get-ADComputer -Filter {OperatingSystem -NotLike “*server*”}...
View ArticleReply To: Null-valued expression after starting RemoteRegistry service
Got a workaround in place, but still no idea why it wasn’t working originally… function OpenRemoteRegistryKey { Param(...
View ArticleReply To: Pipeline and non-pipelined input?
When you use Select-Object, you’re still producing a complex object with properties, as you’ve seen.Get-ADComputer -filter * | Select -Expand Name | My-FunctionIs one option. Extract (expand) the...
View ArticleReply To: Save the output of powershell script
I’m not sure what you mean by “get the output in a single file within the script”. Do you mean all of the output should wind up in a single text file? Or do you mean all of the code should be in a...
View ArticleReply To: Null-valued expression after starting RemoteRegistry service
Your OpenRemoteRegistryKey function has a bug. In both places where you’re calling the function recursively, you should assign the result to $reg; as written, you’re just throwing the result away (and...
View ArticleReply To: Null-valued expression after starting RemoteRegistry service
Actually, now that I think about it, my description of the bug probably wasn’t accurate. It wasn’t that you were throwing away the results of the recursive call (because PowerShell should still write...
View ArticleReply To: Save the output of powershell script
Thanks Dave, i meant all of the output should wind up in a single text file….Please let me know if you have any questions….
View ArticleReply To: Save the output of powershell script
Here is code I use. The if($Host.Name…) will start the transcripting only if not running in the ISE, since ISE does not support transcript files. $now=Get-Date -format "yyyyMMdd_HHmmss"if ($Host.Name...
View ArticleReply To: Using session to add central module path to remote machines
$env can only change the path for the CURRENT process. That’s a Windows thing. Take a look at the discussion at http://powershell.org/wp/forums/topic/invoke-command-to-set-psmodulepath/.
View ArticleTry/Catch Blocks
Simple question. Guess I could test it and see what happens, but right now (honestly) I barely have time to post this question. I’m getting tired of 70-hour weeks! Can a catch block contain it’s own...
View ArticleReply To: Save the output of powershell script
Both of the modules I posted can do that, though the second one is easier to use (requires fewer changes to your existing script): # At beginning of script (either in the Begin block, if you're using...
View ArticleReply To: Save the output of powershell script
Start-Transcript is another option. The main disadvantages of that command versus the PSLogging module are that Start-Transcript doesn’t work from the ISE, and you can only have one transcript going...
View ArticleReply To: Using session to add central module path to remote machines
Rather than updating the PSModulePath variable on all your machines, a possible alternative is to use a full path to the module in the Import-Module command of whatever scripts are using it. I haven’t...
View ArticleConvertTo-HTML inserts empty table tag
When using ConvertTo-HTML with no input object and only -body and -head tags, the output contains a trailing set of empty <table> tags. This causes some minor graphical glitching when emailing...
View ArticleReply To: ConvertTo-HTML inserts empty table tag
There is no option to do so, no. It’d be listed in the command’s help if there was. I’d say a workaround might be to pass the string (non-breaking space) to -InputObject, but I haven’t tried that. I...
View ArticleHelp deciphering powershell code
Can you please help me decipher the following code:0..0xff | %{ $i=0 } { $i = ($i + $b[$_] + $keySeed[$_]) -band 0xff; $b[$_],$b[$i] = $b[$i],$b[$_] }I am trying to convert to C# .net. I understand the...
View ArticleReply To: Save the output of powershell script
Thansk a lot David and Doug for your quick response.. you guys are really awesome and helpful….
View ArticleReply To: Help deciphering powershell code
This is how you “swap” two values. $b[$_] takes on the value of $b[$i] $b[$i] takes on the original value of $b[$_]
View ArticleReply To: Help deciphering powershell code
The section you highlighted ($b[$_],$b[$i] = $b[$i],$b[$_]) will swap two values in array $b: the one at index $_ with the one at index $i.Also for reference if others are curious, this snippet comes...
View Article