运行带有加密凭据的命令

时间:2015-12-08 14:55:22

标签: powershell-v3.0

我想在下面的脚本中使用加密凭据运行几个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。如何实现呢?

0 个答案:

没有答案