Skip to content

Instantly share code, notes, and snippets.

@nathanmcnulty
Created October 24, 2023 22:50
Show Gist options
  • Save nathanmcnulty/f991ad95d356bd43e4b2c5fcc57c2ae2 to your computer and use it in GitHub Desktop.
Save nathanmcnulty/f991ad95d356bd43e4b2c5fcc57c2ae2 to your computer and use it in GitHub Desktop.
Use LAPS to get user profile folder list
Get-ADComputer -Filter * | ForEach-Object {
$laps = (Get-LapsADPassword $_)
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $laps.Account, $laps.Password
Invoke-Command -ComputerName $_ -Credential $cred -ScriptBlock { $env:COMPUTERNAME; (Get-ChildItem).Name }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment