Skip to content

Instantly share code, notes, and snippets.

@hackingbutlegal
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackingbutlegal/3d37c3539352c2e2f73e to your computer and use it in GitHub Desktop.
Save hackingbutlegal/3d37c3539352c2e2f73e to your computer and use it in GitHub Desktop.
PowerShell script to pull Windows startup items
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
@hackingbutlegal
Copy link
Author

Courtesy of my colleague B. Hjella. Prerequisite: you need RSAT installed to run Get-ADComputer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment