Last active
August 29, 2015 14:07
-
-
Save hackingbutlegal/3d37c3539352c2e2f73e to your computer and use it in GitHub Desktop.
PowerShell script to pull Windows startup items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Host,StarupProcess" > StartupProcesses.csv | |
Get-ADComputer -filter {OperatingSystem -like "*Windows*"} | foreach { $_.Name} > computers.txt | |
foreach ($x in (get-content computers.txt) ) | |
{ | |
if (Test-Connection -Count 1 -computername $x) { | |
$Object = Get-WmiObject -Class Win32_StartupCommand -computername $x | |
foreach ($y in $Object.Command) { | |
echo "$x,$y" >> StartupProcesses.csv | |
} | |
} else { | |
echo "$x,CouldNotConnect" >> StartupProcesses.csv | |
} | |
} | |
del computers.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Courtesy of my colleague B. Hjella. Prerequisite: you need RSAT installed to run Get-ADComputer.