Hi,
I have a powershell script myscript.ps1 that is run from a batch file. I use the following command
C:\PSScripts>powershell "& 'c:\psscripts\pausevm.ps1' "
I get an error message (end of the message).
The reason seems to be that when i run this command it launches a powershell that does not have the vm cmdlets. The powershell that i run from the start menu > Windows Powershell - Virtual Machine Manager is the version that I need to run. How can i get this powershell to load instead of the one without the vm cmdlets using the batch file.
Thanks
Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\M
icrosoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
At C:\psscripts\pausevm.ps1:14 char:20
+ set-executionpolicy <<<< RemoteSigned
+ CategoryInfo : NotSpecified: (:) [Set-ExecutionPolicy], Unautho
rizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow
erShell.Commands.SetExecutionPolicyCommand
The term 'Get-VMMServer' is not recognized as the name of a cmdlet, function, s
cript file, or operable program. Check the spelling of the name, or if a path w
as included, verify that the path is correct and try again.
At C:\psscripts\pausevm.ps1:16 char:14
+ Get-VMMServer <<<< chimay
+ CategoryInfo : ObjectNotFound: (Get-VMMServer:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The term 'Get-VM' is not recognized as the name of a cmdlet, function, script f
ile, or operable program. Check the spelling of the name, or if a path was incl
uded, verify that the path is correct and try again.
At C:\psscripts\pausevm.ps1:18 char:7
+ Get-VM <<<< | Where-Object {$_.Tag -eq 'pause'} | Suspend-VM
+ CategoryInfo : ObjectNotFound: (Get-VM:String) [], CommandNotFo
undException
+ FullyQualifiedErrorId : CommandNotFoundException