Hi there,
I'm trying to run a powershell script from a cmd file with the VMware snapin added. Here's what I'm trying to run:
PowerShell.exe -noexit Add-PSSnapin VMware.VimAutomation.Core | k:\work\DeployVM.ps1
It adds the snapin, but then launches the ps1 in notepad which is obviously not what I'm after. I'm sure it's something simple that I'm missing, but I just can't get it. The reason why I want to run it this way is to associate it with a vb button, I've got everything else sorted, just this last bit I need to finish it off.
Cheers,
Josh
If there is a reason you are not adding the Add-PSSnapin VMware.VimAutomation.Core as the first line of your script then you can run it as below:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" " & "C:\MyScript.ps1
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
If there is a reason you are not adding the Add-PSSnapin VMware.VimAutomation.Core as the first line of your script then you can run it as below:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" " & "C:\MyScript.ps1
If you found this information useful, please consider awarding points for Correct or Helpful.
Alan Renouf
Worked like a charm.
Thanks for that.