Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Computer=Read-Host "Enter Computer Name"
- $Username="$Computer\Administrator"
- $domain= (Get-ADDomainController).Domain
- $AdminUser=$env:USERNAME
- $Password=Get-ADComputer -Identity $Computer -Properties * | Select-Object -ExpandProperty ms-Mcs-AdmPwd | ConvertTo-SecureString -AsPlainText -Force
- if(!$Password){$Password=Read-Host "No LAPS Password found / Enter Local Admin Password" | ConvertTo-SecureString -AsPlainText -Force}
- $MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$Password
- Invoke-Command -ComputerName $Computer -ArgumentList $domain,$AdminUser -ScriptBlock {$TestSecChannel=Test-ComputerSecureChannel;
- if ($TestSecChannel -eq $true){Write-Host "The secure channel between the local computer and the domain "$args[0]" is in good condition."-ForegroundColor Green}
- else{$repair=Test-ComputerSecureChannel -Repair -Server $args[0] -Credential $args[1];
- write-host "Secure Channel in bad condition"-ForegroundColor Red;
- if((Test-ComputerSecureChannel) -eq $true){Write-Host "Secure Channel Repaired"-ForegroundColor Yellow}}} -Credential $MySecureCreds
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement