Powershell

A question arised on the Microsoft Live-tour how to run powershell-scripts as logon-scripts. The way to do it is the same as how to run powershell-commands from vb-script. You need to create a “wrapper” or call your ps1-script from vb-script through wscript.shell. Like this:

Dim objShell,objFSO,objFile
Set objShell=CreateObject(“WScript.Shell”)
Set objFSO=CreateObject(“Scripting.FileSystemObject”)
‘sökväg till skriptet
strPath=”c:scriptUpdate-Exchange.ps1″
If objFSO.FileExists(strPath) Then
set objFile=objFSO.GetFile(strPath)
strCMD=”powershell -nologo -command ” & Chr(34) & “&{” &_ objFile.ShortPath & “}” & Chr(34)
‘WScript.Echo strCMD
‘0 gömmer fönstret
‘1 visar fönstret
objShell.Run strCMD,0
Else
WScript.Echo “Hittar inte ” & strPath
WScript.Quit
End If