Last active
September 3, 2018 20:03
-
-
Save mczerniawski/ab34d20b30668981f06e1b86759950cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $ComputerName = 'SomeComputer' | |
| $LAPSPassword = (Get-AdmPwdPassword -ComputerName $ComputerName -ErrorAction SilentlyContinue).Password | |
| If ($LAPSPassword) { | |
| $LocalAdminPassword = ConvertTo-SecureString -String $LAPSPassword -AsPlainText -Force | |
| $LocalAdminCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "$ComputerName\Administrator", $LocalAdminPassword | |
| $LocalAdminCredential | |
| } | |
| Else { | |
| Write-error "No LAPS password for computer {$ComputerName}" | |
| $Null | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment