powershell-v2.0

Start-job vs. Invoke-command -asjob

I'm trying to do basic background jobs in PowerShell 2.0, and I'm seeing different things with start-job and invoke-command -asjob. If I do this: start-job -scriptblock {get-process} I get a job object, but the child job (which is created automatically by start-job) always has a JobStateInfo of "NotStarted". this, however, works as e...

Gvim, MinGW and Powershell making them work the CLI way.

Just shifted to windows7. Liking it :). Is there a way to install MinGW in windows, such that, i can cd to my code directory (which is different from MinGW install directory) and compile my code there. IF, no then what is the equivalent of $PATH (bourne shell) in windows, and how shall i set it. Can this trick (setting MinGW in default...

Creat AppPool and virtual directory on a remote server using Powershell

How do I creat AppPool and virtual directory on a remote server using Powershell on iis6 ...

Psake, Powershell & Wix

I have the below function as a part of my psake build. When the build is executing Candle.exe throws this error: candle.exe : warning CNDL1098: 'ext .\Build\Packages\WixWeb\bin\WixIIsExtension.dll' is not a valid command line argument. I think this is a problem with the way I am passing command line args but I cannot for the life of m...

Powershell ISE appears to hand with interactive commands.

I just download Powershell 2.0 and using the ISE. In general I really like it but I am looking for a workaround on a gotcha. There are a lot of legacy commands which are interactive. For example xcopy will prompt the user by default if it is told to overwrite a file. In the Powershell ISE this appears to hang mkdir c:\tmp cd c:\tmp d...

Passing parameters in PowerShell 2.0

I have the following test defined in a psake build script: task package -depends create_wix_content_fragment { & $candle -dProductName=Foo ` -dVersion=$version ` -dProductID=0cd64670-5769-4e34-8b21-c6242e7ca5a2 ` -dUpgradeCode=307601e9-4eea-4b5c-938a-354115d5c419 ` -dAppPool=FooAppPool ` ...

Click a javascript url using Powershell Internet Explorer automation

Given the following html: <HTML> <BODY> <DIV id="admin" onmouseover="javascript:showLayer('admin');" onmouseout="javascript:hideLayer('admin');" name="admin"> <TABLE > <TBODY> <TR> <TD class="popup" > <A href="javascript:doTab(3, 'muskrat.htm','docrat.htm')">User Admin</A> </TD></TR></TBODY></TABLE></DIV></BODY></HTML> How wou...

Determine What Version of PowerShell is Installed?

Hi, How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all? Thanks, MagicAndi ...

Determine If Solution Compiles using MSBuild and PSake

Hi, I have put together a PSake (v2.0) build script, and the script is setting the $psake.build_success property as true even thought the call to MSBuild fails. Can anyone advise me on how to alter the script so that the $psake.build_success property will correctly return false when the MSBuild call fails? My PSake build script is a...

powershell and console app output

Im trying to automate video conversion with powershell and ffmpeg tool. Ffmpeg have detailed output about video if called without all nessesary parameters. Usually it reports about error and display input file info if one specified. Ex I interactively executed such command: d:\video.Enc\ffmpeg.exe -i d:\video.Enc\1.wmv this is po...

Load variables from another powershell script

I have several scripts that could be reusing variables so I'd like to isolate variables in their own Variables.ps1 script, i.e. $var1 = "1" $var2 = "2" I'm trying to load these variables then print them out in the Main.ps1 script like this: .\Variables.ps1 $var1 $var2 This works if I first run .\Variables.ps1 but not if I just run ...

delete files from ftp with powershell

I need a script that will delete all files from a ftp directory, and then upload a folder on my local machine to that same ftp location. Any ideas?? Thanks in advance ...

Loading .net 4.0 beta2 assembly in PowerShell 2.0

I tried loading PresentationFramework.dll from .net 4.0 beta2 in PowerShell v2.0. But it fails with the following error. PS C:\Windows\system32> [Reflection.Assembly]::LoadFile("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationF ramework.dll") Exception calling "LoadFile" with "1" argument(s): "This assembly is built by a ...

What exactly does PowerShell's -Version parameter do?

PowerShell's help (powershell -?) states: -Version Starts the specified version of Windows PowerShell. However, when starting PowerShell 2 with powershell -Version 1 all things I tried that are only present in v2 and not v1 still work, such as the -split operator or the Get-Random cmdlet. So what exactly changes when running Power...

Powershell event forwarding

Hi. Sorry for bad english. I have some troubles with powershell and events forwarding mechanism in it. Im trying to do something like this: $remoteComputer = "." $session = New-PsSession $remoteComputer Unregister-Event CatchEvent -ErrorAction SilentlyContinue Invoke-Command $session { ## The WMI query to detect a stopping servic...

PowerShell command to parameterised PowerShell function?

I'm not so hot with PowerShell yet, but have managed to get this command to work quite nicely: get-childitem "C:\Code\WC1" -Recurse | select-string "insert into\s+my_table" Thing is, I know I'm going to struggle to remember this, so how can I make it into a function where the path supplied to get-childitem and the search regex are par...

How to write Powershell help for my cmdlets

I've written my own Powershell cmdlets in c#. How can I add help test, so the I can get a more complete description when users use "Get-Help MYCMDLET" Thanks, ...

WMI query issue in PowerShell

Here is where I have started: #Get Physical Memory function getwmiinfo ($svr) { gwmi -query "select * from Win32_PhysicalMemory" -computername $svr | select [$svr], DeviceLocator } $Servers = get-content -path "C:\test.txt" foreach($Servers in $Servers) { getwmiinfo $Servers } I get this: [risk] Devic...

Importing CSV from a variable instead of file?

Hi Folks, I have a command that formats it's output in the form of CSV. I have a list of machine this command will run against using a foreach loop. in the below example $serverlist is automatically generated with an AD Query. foreach ($server in $serverlist) { $outputlist = mycommand } what I would like to do is somehow end up wit...

PowerShell 2.0 via C#, return values are empty?

I'm using C# to call Exchange 2010 PowerShell methods and I've just encountered a snag. The Collection returned by the Execute method don't have a BaseObject. I can use .Properties["PropertyName"], but it seems that all those values are string values. Not very practical for file size, Guids and so on. Reading http://blogs.msdn.com/powe...