Powershell Test-ComputerSecureChannel

I’m trying to script a secure channel check that will reconnect the pc automatically. Here is my script :

$username = “username”
$password = ConvertTo-SecureString “password” -AsPlainText -Force

$Credentials = New-Object System.Management.Automation.PSCredential -argumentlist ($username,$password)

Test-ComputerSecureChannel -repair -credential $Credentials

The answer I get is that it cannot reinitialise the channel password for the account in the domain and that the access is denied.

(Exception de HRESULT : 0x80070005 (E_ACCESSDENIED)).

  • CategoryInfo : OperationStopped: (HPGE-449-BP:String) [Test-ComputerSecureChannel], InvalidOperationException
  • FullyQualifiedErrorId : FailToResetPasswordOnDomain,Microsoft.PowerShell.Commands.TestComputerSecureChannelCommand

 

If someone has any answer to this I would be glad to have some help,

Thank you!

You should be using a domain account for this domain\user and the user should have access to perform this task.