Script to check for installed PowerShell and to change ExecutionPolicy.For Windows 2008
More information about this can be found in my blogpost,http://powershellug.com/blogs/thewall/archive/2008/11/12/windows-2008-and-hyper-v-machines-part-2.aspx
My cmd file:depllab.cmd-----------------------------------
@echo offclsEcho Lab Deploy scriptEcho by Fredrik Wall, fredrik.wall@truesec.seEcho.
setlocal
for /f "tokens=*" %%i in ('ver.exe') do set windowsversion=%%i
if "%windowsversion%" == "Microsoft Windows [Version 6.0.6001]" goto PowerShellchkwin2008
:PowerShellchkwin2008Echo Windows 2008 detected on this machineEcho Checking for PowerShell and install it if neededif not exist "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" servermanagercmd.exe -install PowerShellgoto setreg
:setregEcho Checking current status of the Execution Policy for PowerShellfor /f "tokens=*" %%i in ('PowerShell.exe Get-ExecutionPolicy') do set exmode=%%iif not "%exmode%" == "Unrestricted" Echo ExecutionPolicy will be changed to Unrestricted nowif not "%exmode%" == "Unrestricted" PowerShell.exe Set-ExecutionPolicy Unrestrictedif "%exmode%" == "Unrestricted" Echo ExecutionPolicy are set to Unrestrictedgoto runscript
:runscriptPowerShell.exe ".\deplab.ps1"
:end