Y
y2k
Приветствую комрады. Собственно сабж - кто нибудь встречался вот с сием творением?
---------
function Connect-Mstsc {
<#
Description
-----------
This command dot sources the script to ensure the Connect-Mstsc function is available in your current PowerShell session
.EXAMPLE
Connect-Mstsc -computername Mycomputer -UserName mymachine\executeauto -password Idonttellpasswords
param (
[Parameter(Mandatory=$true,Position=0)]
[Alias("CN")]
[string[]]$ComputerName,
[Parameter(Mandatory=$true,Position=1)]
[Alias("U")]
[string]$User,
[Parameter(Mandatory=$true,Position=2)]
[Alias("P")]
[string]$Password
)
process {
foreach ($Computer in $ComputerName) {
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$Process = New-Object System.Diagnostics.Process
$ProcessInfo.FileName = "$($env:SystemRoot)\system32\cmdkey.exe"
$ProcessInfo.Arguments = "/generic:TERMSRV/$Computer /user:$User /pass:$Password"
$Process.StartInfo = $ProcessInfo
$Process.Start()
$ProcessInfo.FileName = "$($env:SystemRoot)\system32\mstsc.exe"
$ProcessInfo.Arguments = "/v $Computer"
$Process.StartInfo = $ProcessInfo
$Process.Start()
}
}
}
------------------------
---------
function Connect-Mstsc {
<#
Description
-----------
This command dot sources the script to ensure the Connect-Mstsc function is available in your current PowerShell session
.EXAMPLE
Connect-Mstsc -computername Mycomputer -UserName mymachine\executeauto -password Idonttellpasswords
param (
[Parameter(Mandatory=$true,Position=0)]
[Alias("CN")]
[string[]]$ComputerName,
[Parameter(Mandatory=$true,Position=1)]
[Alias("U")]
[string]$User,
[Parameter(Mandatory=$true,Position=2)]
[Alias("P")]
[string]$Password
)
process {
foreach ($Computer in $ComputerName) {
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$Process = New-Object System.Diagnostics.Process
$ProcessInfo.FileName = "$($env:SystemRoot)\system32\cmdkey.exe"
$ProcessInfo.Arguments = "/generic:TERMSRV/$Computer /user:$User /pass:$Password"
$Process.StartInfo = $ProcessInfo
$Process.Start()
$ProcessInfo.FileName = "$($env:SystemRoot)\system32\mstsc.exe"
$ProcessInfo.Arguments = "/v $Computer"
$Process.StartInfo = $ProcessInfo
$Process.Start()
}
}
}
------------------------