我想在下面的脚本中使用加密凭据运行几个cmdlet
Import-Module Remotedesktop
$SPAdmin = "domain\username"
$File = "\\myserver\Rduserlogoff\Securestring.txt"
[Byte[]] $key = (1..16)
$Password = Get-Content $File | ConvertTo-SecureString -Key $key
$Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $SPAdmin, $Password
$Username = Read-host "Enter the user name you wish to logoff"
$Broker = Get-connectionbrokerhighavailability -connectionbroker "brokerserver"
$Acbroker = $Broker.Activemanagementserver
write-host $username
$sessiondetails=@(Get-RDusersession -connectionbroker "$Acbroker" | where-object {$_.username -match $username} | Invoke-RDUserLogoff)
应使用加密凭据运行 $Broker
和$sessiondetails
。如何实现呢?