Travel

Categories

Run Windows PowerShell script

1. Name the script as .ps1

2. Under Powershell, remember to set Set-ExecutionPolicy RemoteSigned or Set-ExecutionPolicy Unrestricted

3. To run the powershell script outside powershell :

powershell.exe -noexit c:\scripts\test.ps1 powershell.exe -noexit get-childitem c:\scripts

Call from vbscript Set objShell = CreateObject(“Wscript.Shell”) objShell.Run(“powershell.exe -noexit c:\scripts\test.ps1”)

print pdf in command line under Windows

Assume you have installed Adobe Reader

Under Powershell :

Dir D:\test\S10010025.pdf | Foreach-Object { Start-Process -FilePath $_.FullName –Verb Print }

Or for batch printing

Dir D:\test\*.pdf | Foreach-Object { Start-Process -FilePath $_.FullName –Verb Print }

Or

AcroRd32.exe /s /o /h /t “FULL_PATH_TO_PDF” “PRINTER NAME” “PRINTER DRIVER NAME” “PORT”

AcroRd32.exe /s /o /h /p “FULL_PATH_TO_PDF” for […]

Locate obsolete computer records in AD

http://dmitrysotnikov.wordpress.com/2007/09/07/locate-obsolete-computer-records-in-ad/