Quantcast
Channel: PowerShell.org » All Posts
Browsing all 13067 articles
Browse latest View live

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 Article


Reply 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 Article


Image may be NSFW.
Clik here to view.

Reply 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 Article

Image may be NSFW.
Clik here to view.

Reply 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 Article

Reply 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 Article


Reply 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 Article

Reply 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 Article

Reply 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 Article


Reply 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 Article


Try/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 Article

Reply To: Try/Catch Blocks

Sure.

View Article

Reply 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 Article

Reply 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 Article


Reply 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 Article

ConvertTo-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 Article


Reply 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 Article

Help 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 Article


Reply 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 Article

Reply 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 Article

Image may be NSFW.
Clik here to view.

Reply 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
Browsing all 13067 articles
Browse latest View live