{"id":372859,"date":"2024-05-21T05:22:33","date_gmt":"2024-05-21T05:22:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=372859"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=372859","title":{"rendered":"<span>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (powershell-gui)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430\u0441\u0442\u0430\u043b \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0432\u0441\u0435\u0445 \u0437\u0430\u0440\u0443\u0431\u0435\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 \u0443\u0436\u0430\u0441 \u043e\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u041f\u041e. \u041f\u043e\u0440\u0430\u0437\u043c\u044b\u0441\u043b\u0438\u0432 \u043a\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f 1-\u043b\u0438\u043d\u0438\u0438 \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u043e\u043d\u044f\u043b\u0438:<\/p>\n<ol>\n<li>\n<p>\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u041f\u041a \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u041f\u041a \u0431\u0435\u0437 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e powershell&#8217;a.<\/p>\n<blockquote>\n<p>\u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/winitpro.ru\/index.php\/2019\/07\/18\/modul-active-directory-dlya-powershell\/\" rel=\"noopener noreferrer nofollow\">Active Directory \u0434\u043b\u044f PowerShell<\/a><\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0432 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u044f\u0437\u043a\u0443 \u043b\u043e\u0433\u0438\u043d\/\u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u041f\u041a<\/p>\n<pre><code class=\"powershell\">Add-Type -assembly System.Windows.Forms $window_form = New-Object System.Windows.Forms.Form $window_form.Text ='\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u043b\u0443' $window_form.Width = 240 $window_form.Height = 550 $window_form.StartPosition = 'CenterScreen'  $FormLabel1 = New-Object System.Windows.Forms.Label $FormLabel1.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043d:\" $FormLabel1.Location = New-Object System.Drawing.Point(10,10) $FormLabel1.AutoSize = $true $window_form.Controls.Add($FormLabel1)  $FormTextBox1 = New-Object System.Windows.Forms.TextBox $FormTextBox1.Width = 200 $FormTextBox1.Location = New-Object System.Drawing.Point(10,25)  $FormLabel2 = New-Object System.Windows.Forms.Label $FormLabel2.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c:\" $FormLabel2.Location = New-Object System.Drawing.Point(10,50) $FormLabel2.AutoSize = $true  $FormTextBox2 = New-Object System.Windows.Forms.TextBox $FormTextBox2.Width = 200 $FormTextBox2.text = $NULL $FormTextBox2.Location = New-Object System.Drawing.Point(10,65)  $FormLabel3 = New-Object System.Windows.Forms.Label $FormLabel3.Text = \"\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:\" $FormLabel3.Location = New-Object System.Drawing.Point(10,90) $FormLabel3.AutoSize = $true  $ListBox = New-Object System.Windows.Forms.ListBox $ListBox.Width = 200 $ListBox.Height = 300 $ListBox.Location = New-Object System.Drawing.Point(10,105)  $FormButton = New-Object System.Windows.Forms.Button $FormButton.Location = New-Object System.Drawing.Size(10,400) $FormButton.Size = New-Object System.Drawing.Size(200,30) $FormButton.Text = \"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\" $window_form.AcceptButton = $FormButton  $FormButton2 = New-Object System.Windows.Forms.Button $FormButton2.Location = New-Object System.Drawing.Size(10,440) $FormButton2.Size = New-Object System.Drawing.Size(200,30) $FormButton2.Text = \"\u0417\u0430\u043a\u0440\u044b\u0442\u044c\" $window_form.CancelButton = $FormButton3 $FormButton2.Add_Click({$window_form.Close();$window_form.Visible=$false})  $FormLabel4 = New-Object System.Windows.Forms.Label $FormLabel4.Text = \"\" $FormLabel4.Location = New-Object System.Drawing.Point(10,480) $FormLabel4.AutoSize = $true  $window_form.Controls.Add($FormButton) $window_form.Controls.Add($FormButton2) $window_form.Controls.Add($ListBox) $window_form.Controls.Add($FormTextBox1) $window_form.Controls.Add($FormTextBox2) $window_form.Controls.Add($FormLabel1) $window_form.Controls.Add($FormLabel2) $window_form.Controls.Add($FormLabel3) $window_form.Controls.Add($FormLabel4)  $window_form.Add_Shown({$FormTextBox1.Select()}) $window_form.Topmost = $true $window_form.MaximizeBox = $false  $result = $window_form.ShowDialog()<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0435 \u043b\u043e\u0433\u0438\u043d\u043e\u043c, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u043b\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0441\u043e \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430\u043c\u0438 \u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u041f\u041a<\/p>\n<pre><code class=\"powershell\"># \u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0430\u0448 \u0434\u043e\u043c\u0435\u043d \u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f $FormTextBox1.text = \"$Env:UserDomain\\$Env:UserName\"  # \u041f\u043e\u043b\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043a\u0440\u044b\u0442\u044b\u043c $FormTextBox2.PasswordChar = '*'  # \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0432\u043e\u0439 OU \u0438 \u0434\u043e\u043c\u0435\u043d $OU = \"OU=Computers,DC=domain,DC=local\"  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u041f\u041a \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u041f\u041a $comps = (Get-ADComputer -SearchBase $OU -Filter *).Name | Sort-Object ForEach ($comp in $comps){     [void] $listBox.Items.Add($comp)     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 $FormButton \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0435\u0430\u043d\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041a \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0430\u043d\u0441\u0443<\/p>\n<pre><code class=\"powershell\"># \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 $FormButton.Add_Click({  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043c\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u041f\u041a \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 $ps = $listBox.SelectedItem.ToString()  # \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $pwsecur = ConvertTo-SecureString -String $FormTextBox2.text -AsPlainText -Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $FormTextBox1.text, $pwsecur  # \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0441\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041a \u0438 \u0438\u0449\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e   $active_sessions = quser \/server:$ps | foreach {($_ -replace \"\\s\\s+\",\",\")} | ConvertFrom-Csv     ForEach ($active_session in $active_sessions) {             #\u041d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b \u0432\u0435\u0440\u0441\u0438\u0438         if (($active_session.\u0421\u0422\u0410\u0422\u0423\u0421 -eq '\u0410\u043a\u0442\u0438\u0432\u043d\u043e') -or ($active_session.STATUS -eq 'Active')){             $id = $active_session.ID             }  # \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 Start-Process -FilePath \"mstsc\" -ArgumentList \"\/v:$ps \/shadow:$id \/control \/noconsentprompt\" -Credential $Cred -Wait -WindowStyle Maximized<\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0433\u043e\u0442\u043e\u0432, \u0431\u0435\u0436\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u043e\u043b\u0435 \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u043d \u041f\u041a<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0440\u0430 \u043b\u043e\u0433\u0438\u043d\/\u043f\u0430\u0440\u043e\u043b\u044c (\u0432\u0435\u0440\u043d\u044b\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u041f\u041a<\/p>\n<\/li>\n<\/ol>\n<p>\u0421 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u043f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"powershell\">[Console]::outputEncoding = [System.Text.Encoding]::GetEncoding('cp866')  $OU = \"OU=Computers,DC=domain,DC=local\"  Add-Type -assembly System.Windows.Forms $window_form = New-Object System.Windows.Forms.Form $window_form.Text ='\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u043b\u0443' $window_form.Width = 240 $window_form.Height = 550 $window_form.StartPosition = 'CenterScreen'  $FormLabel1 = New-Object System.Windows.Forms.Label $FormLabel1.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043d:\" $FormLabel1.Location = New-Object System.Drawing.Point(10,10) $FormLabel1.AutoSize = $true $window_form.Controls.Add($FormLabel1)  $FormTextBox1 = New-Object System.Windows.Forms.TextBox $FormTextBox1.Width = 200 $FormTextBox1.text = \"$Env:UserDomain\\$Env:UserName\" $FormTextBox1.Location = New-Object System.Drawing.Point(10,25)  $FormLabel2 = New-Object System.Windows.Forms.Label $FormLabel2.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c:\" $FormLabel2.Location = New-Object System.Drawing.Point(10,50) $FormLabel2.AutoSize = $true  $FormTextBox2 = New-Object System.Windows.Forms.TextBox $FormTextBox2.Width = 200 $FormTextBox2.text = $NULL $FormTextBox2.PasswordChar = '*' $FormTextBox2.Location = New-Object System.Drawing.Point(10,65)  $FormLabel3 = New-Object System.Windows.Forms.Label $FormLabel3.Text = \"\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:\" $FormLabel3.Location = New-Object System.Drawing.Point(10,90) $FormLabel3.AutoSize = $true  $ListBox = New-Object System.Windows.Forms.ListBox $ListBox.Width = 200 $ListBox.Height = 300 $ListBox.Location = New-Object System.Drawing.Point(10,105) $comps = (Get-ADComputer -SearchBase $OU -Filter *).Name | Sort-Object ForEach ($comp in $comps){     [void] $listBox.Items.Add($comp)     }  $FormButton = New-Object System.Windows.Forms.Button $FormButton.Location = New-Object System.Drawing.Size(10,400) $FormButton.Size = New-Object System.Drawing.Size(200,30) $FormButton.Text = \"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\" $window_form.AcceptButton = $FormButton $FormButton.Add_Click({     $ps = $listBox.SelectedItem.ToString()     If (($FormTextBox2.text).Length -gt 1){     If ($ps -ne $NULL){         Function Test-ADAuthentication {             param($username,$password)             (new-object directoryservices.directoryentry \"\",$username,$password).psbase.name -ne $null         }         $testcred = Test-ADAuthentication $FormTextBox1.text $FormTextBox2.text         If ($testcred -eq 'True'){         If (Test-Connection $ps -Count 1 -Quiet){         $FormLabel4.Text = \"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f...\"     $pwsecur = ConvertTo-SecureString -String $FormTextBox2.text -AsPlainText -Force     $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $FormTextBox1.text, $pwsecur     Invoke-Command \u2013ComputerName $ps -Credential $cred \u2013ScriptBlock {New-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Terminal Services' -Name 'Shadow' -Value '2' -PropertyType 'DWord'}     Invoke-Command \u2013ComputerName $ps -Credential $cred \u2013ScriptBlock {New-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Terminal Services' -Name 'AllowRemoteRPC' -Value '1' -PropertyType 'DWord'}     $active_sessions = quser \/server:$ps | foreach {($_ -replace \"\\s\\s+\",\",\")} | ConvertFrom-Csv     ForEach ($active_session in $active_sessions) {             #\u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0430\u043d\u0433 \u044f\u0437\u044b\u043a\u0435         if (($active_session.\u0421\u0422\u0410\u0422\u0423\u0421 -eq '\u0410\u043a\u0442\u0438\u0432\u043d\u043e') -or ($active_session.STATUS -eq 'Active')){             $id = $active_session.ID             }     }  Start-Process -FilePath \"mstsc\" -ArgumentList \"\/v:$ps \/shadow:$id \/control \/noconsentprompt\" -Credential $Cred -Wait -WindowStyle Maximized  }else {     $FormLabel4.Text = \"\u041a\u041e\u041c\u041f\u042c\u042e\u0422\u0415\u0420 \u041d\u0415 \u0414\u041e\u0421\u0422\u0423\u041f\u0415\u041d!\" }  }else {     $FormLabel4.Text = \"\u041b\u041e\u0413\u0418\u041d \u0418\u041b\u0418 \u041f\u0410\u0420\u041e\u041b\u042c \u041d\u0415 \u0412\u0415\u0420\u041d\u042b\u0415!\" }  }else {     $FormLabel4.Text = \"\u0412\u042b \u041d\u0415 \u0412\u042b\u0411\u0420\u0410\u041b\u0418 \u041a\u041e\u041c\u041f\u042c\u042e\u0422\u0415\u0420!\" }  }else {     $FormLabel4.Text = \"\u0412\u042b \u041d\u0415 \u0412\u0412\u0415\u041b\u0418 \u041f\u0410\u0420\u041e\u041b\u042c!\" }  })  $FormButton2 = New-Object System.Windows.Forms.Button $FormButton2.Location = New-Object System.Drawing.Size(10,440) $FormButton2.Size = New-Object System.Drawing.Size(200,30) $FormButton2.Text = \"\u0417\u0430\u043a\u0440\u044b\u0442\u044c\" $window_form.CancelButton = $FormButton3 $FormButton2.Add_Click({$window_form.Close();$window_form.Visible=$false})  $FormLabel4 = New-Object System.Windows.Forms.Label $FormLabel4.Text = \"\" $FormLabel4.Location = New-Object System.Drawing.Point(10,480) $FormLabel4.AutoSize = $true  $window_form.Controls.Add($FormButton) $window_form.Controls.Add($FormButton2) $window_form.Controls.Add($ListBox) $window_form.Controls.Add($FormTextBox1) $window_form.Controls.Add($FormTextBox2) $window_form.Controls.Add($FormLabel1) $window_form.Controls.Add($FormLabel2) $window_form.Controls.Add($FormLabel3) $window_form.Controls.Add($FormLabel4)  $window_form.Add_Shown({$FormTextBox1.Select()}) $window_form.Topmost = $true $window_form.MaximizeBox = $false  $result = $window_form.ShowDialog()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>Powershell \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0436\u0443\u0442\u043a\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. \u0415\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <a href=\"https:\/\/fixmypc.ru\/post\/konvertiruem-skripty-powershell-s-formata-ps1-v-exe-na-primerakh\/\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/a> \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 exe \u0444\u0430\u0439\u043b<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/805691\/\"> https:\/\/habr.com\/ru\/articles\/805691\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430\u0441\u0442\u0430\u043b \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0432\u0441\u0435\u0445 \u0437\u0430\u0440\u0443\u0431\u0435\u0436\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0432\u043e \u0432\u0441\u044f\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 \u0443\u0436\u0430\u0441 \u043e\u0442 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u041f\u041e. \u041f\u043e\u0440\u0430\u0437\u043c\u044b\u0441\u043b\u0438\u0432 \u043a\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f 1-\u043b\u0438\u043d\u0438\u0438 \u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u043e\u043d\u044f\u043b\u0438:<\/p>\n<ol>\n<li>\n<p>\u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u041f\u041a \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u041f\u041a \u0431\u0435\u0437 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e powershell&#8217;a.<\/p>\n<blockquote>\n<p>\u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/winitpro.ru\/index.php\/2019\/07\/18\/modul-active-directory-dlya-powershell\/\" rel=\"noopener noreferrer nofollow\">Active Directory \u0434\u043b\u044f PowerShell<\/a><\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u043e\u0440\u043c\u0443 \u0432 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u044f\u0437\u043a\u0443 \u043b\u043e\u0433\u0438\u043d\/\u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u041f\u041a<\/p>\n<pre><code class=\"powershell\">Add-Type -assembly System.Windows.Forms $window_form = New-Object System.Windows.Forms.Form $window_form.Text ='\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u043b\u0443' $window_form.Width = 240 $window_form.Height = 550 $window_form.StartPosition = 'CenterScreen'  $FormLabel1 = New-Object System.Windows.Forms.Label $FormLabel1.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043d:\" $FormLabel1.Location = New-Object System.Drawing.Point(10,10) $FormLabel1.AutoSize = $true $window_form.Controls.Add($FormLabel1)  $FormTextBox1 = New-Object System.Windows.Forms.TextBox $FormTextBox1.Width = 200 $FormTextBox1.Location = New-Object System.Drawing.Point(10,25)  $FormLabel2 = New-Object System.Windows.Forms.Label $FormLabel2.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c:\" $FormLabel2.Location = New-Object System.Drawing.Point(10,50) $FormLabel2.AutoSize = $true  $FormTextBox2 = New-Object System.Windows.Forms.TextBox $FormTextBox2.Width = 200 $FormTextBox2.text = $NULL $FormTextBox2.Location = New-Object System.Drawing.Point(10,65)  $FormLabel3 = New-Object System.Windows.Forms.Label $FormLabel3.Text = \"\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:\" $FormLabel3.Location = New-Object System.Drawing.Point(10,90) $FormLabel3.AutoSize = $true  $ListBox = New-Object System.Windows.Forms.ListBox $ListBox.Width = 200 $ListBox.Height = 300 $ListBox.Location = New-Object System.Drawing.Point(10,105)  $FormButton = New-Object System.Windows.Forms.Button $FormButton.Location = New-Object System.Drawing.Size(10,400) $FormButton.Size = New-Object System.Drawing.Size(200,30) $FormButton.Text = \"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\" $window_form.AcceptButton = $FormButton  $FormButton2 = New-Object System.Windows.Forms.Button $FormButton2.Location = New-Object System.Drawing.Size(10,440) $FormButton2.Size = New-Object System.Drawing.Size(200,30) $FormButton2.Text = \"\u0417\u0430\u043a\u0440\u044b\u0442\u044c\" $window_form.CancelButton = $FormButton3 $FormButton2.Add_Click({$window_form.Close();$window_form.Visible=$false})  $FormLabel4 = New-Object System.Windows.Forms.Label $FormLabel4.Text = \"\" $FormLabel4.Location = New-Object System.Drawing.Point(10,480) $FormLabel4.AutoSize = $true  $window_form.Controls.Add($FormButton) $window_form.Controls.Add($FormButton2) $window_form.Controls.Add($ListBox) $window_form.Controls.Add($FormTextBox1) $window_form.Controls.Add($FormTextBox2) $window_form.Controls.Add($FormLabel1) $window_form.Controls.Add($FormLabel2) $window_form.Controls.Add($FormLabel3) $window_form.Controls.Add($FormLabel4)  $window_form.Add_Shown({$FormTextBox1.Select()}) $window_form.Topmost = $true $window_form.MaximizeBox = $false  $result = $window_form.ShowDialog()<\/code><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0435 \u043b\u043e\u0433\u0438\u043d\u043e\u043c, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u043b\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0441\u043e \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430\u043c\u0438 \u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u041f\u041a<\/p>\n<pre><code class=\"powershell\"># \u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0430\u0448 \u0434\u043e\u043c\u0435\u043d \u0438 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f $FormTextBox1.text = \"$Env:UserDomain\\$Env:UserName\"  # \u041f\u043e\u043b\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043a\u0440\u044b\u0442\u044b\u043c $FormTextBox2.PasswordChar = '*'  # \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0432\u043e\u0439 OU \u0438 \u0434\u043e\u043c\u0435\u043d $OU = \"OU=Computers,DC=domain,DC=local\"  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u041f\u041a \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u041f\u041a $comps = (Get-ADComputer -SearchBase $OU -Filter *).Name | Sort-Object ForEach ($comp in $comps){     [void] $listBox.Items.Add($comp)     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 $FormButton \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0435\u0430\u043d\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041a \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0430\u043d\u0441\u0443<\/p>\n<pre><code class=\"powershell\"># \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043d\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 $FormButton.Add_Click({  # \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043c\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u041f\u041a \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 $ps = $listBox.SelectedItem.ToString()  # \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $pwsecur = ConvertTo-SecureString -String $FormTextBox2.text -AsPlainText -Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $FormTextBox1.text, $pwsecur  # \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0441\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u041f\u041a \u0438 \u0438\u0449\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e   $active_sessions = quser \/server:$ps | foreach {($_ -replace \"\\s\\s+\",\",\")} | ConvertFrom-Csv     ForEach ($active_session in $active_sessions) {             #\u041d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b \u0432\u0435\u0440\u0441\u0438\u0438         if (($active_session.\u0421\u0422\u0410\u0422\u0423\u0421 -eq '\u0410\u043a\u0442\u0438\u0432\u043d\u043e') -or ($active_session.STATUS -eq 'Active')){             $id = $active_session.ID             }  # \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 Start-Process -FilePath \"mstsc\" -ArgumentList \"\/v:$ps \/shadow:$id \/control \/noconsentprompt\" -Credential $Cred -Wait -WindowStyle Maximized<\/code><\/pre>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0433\u043e\u0442\u043e\u0432, \u0431\u0435\u0436\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u043e\u043b\u0435 \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0431\u0440\u0430\u043d \u041f\u041a<\/p>\n<\/li>\n<li>\n<p>\u041f\u0430\u0440\u0430 \u043b\u043e\u0433\u0438\u043d\/\u043f\u0430\u0440\u043e\u043b\u044c (\u0432\u0435\u0440\u043d\u044b\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u041f\u041a<\/p>\n<\/li>\n<\/ol>\n<p>\u0421 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u043f\u043e\u043b\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a<\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"powershell\">[Console]::outputEncoding = [System.Text.Encoding]::GetEncoding('cp866')  $OU = \"OU=Computers,DC=domain,DC=local\"  Add-Type -assembly System.Windows.Forms $window_form = New-Object System.Windows.Forms.Form $window_form.Text ='\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u043b\u0443' $window_form.Width = 240 $window_form.Height = 550 $window_form.StartPosition = 'CenterScreen'  $FormLabel1 = New-Object System.Windows.Forms.Label $FormLabel1.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043d:\" $FormLabel1.Location = New-Object System.Drawing.Point(10,10) $FormLabel1.AutoSize = $true $window_form.Controls.Add($FormLabel1)  $FormTextBox1 = New-Object System.Windows.Forms.TextBox $FormTextBox1.Width = 200 $FormTextBox1.text = \"$Env:UserDomain\\$Env:UserName\" $FormTextBox1.Location = New-Object System.Drawing.Point(10,25)  $FormLabel2 = New-Object System.Windows.Forms.Label $FormLabel2.Text = \"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u0430\u0440\u043e\u043b\u044c:\" $FormLabel2.Location = New-Object System.Drawing.Point(10,50) $FormLabel2.AutoSize = $true  $FormTextBox2 = New-Object System.Windows.Forms.TextBox $FormTextBox2.Width = 200 $FormTextBox2.text = $NULL $FormTextBox2.PasswordChar = '*' $FormTextBox2.Location = New-Object System.Drawing.Point(10,65)  $FormLabel3 = New-Object System.Windows.Forms.Label $FormLabel3.Text = \"\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f:\" $FormLabel3.Location = New-Object System.Drawing.Point(10,90) $FormLabel3.AutoSize = $true  $ListBox = New-Object System.Windows.Forms.ListBox $ListBox.Width = 200 $ListBox.Height = 300 $ListBox.Location = New-Object System.Drawing.Point(10,105) $comps = (Get-ADComputer -SearchBase $OU -Filter *).Name | Sort-Object ForEach ($comp in $comps){     [void] $listBox.Items.Add($comp)     }  $FormButton = New-Object System.Windows.Forms.Button $FormButton.Location = New-Object System.Drawing.Size(10,400) $FormButton.Size = New-Object System.Drawing.Size(200,30) $FormButton.Text = \"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\" $window_form.AcceptButton = $FormButton $FormButton.Add_Click({     $ps = $listBox.SelectedItem.ToString()     If (($FormTextBox2.text).Length -gt 1){     If ($ps -ne $NULL){         Function Test-ADAuthentication {             param($username,$password)             (new-object directoryservices.directoryentry \"\",$username,$password).psbase.name -ne $null         }         $testcred = Test-ADAuthentication $FormTextBox1.text $FormTextBox2.text         If ($testcred -eq 'True'){         If (Test-Connection $ps -Count 1 -Quiet){         $FormLabel4.Text = \"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f...\"     $pwsecur = ConvertTo-SecureString -String $FormTextBox2.text -AsPlainText -Force     $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $FormTextBox1.text, $pwsecur     Invoke-Command \u2013ComputerName $ps -Credential $cred \u2013ScriptBlock {New-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Terminal Services' -Name 'Shadow' -Value '2' -PropertyType 'DWord'}     Invoke-Command \u2013ComputerName $ps -Credential $cred \u2013ScriptBlock {New-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\Terminal Services' -Name 'AllowRemoteRPC' -Value '1' -PropertyType 'DWord'}     $active_sessions = quser \/server:$ps | foreach {($_ -replace \"\\s\\s+\",\",\")} | ConvertFrom-Csv     ForEach ($active_session in $active_sessions) {             #\u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0430\u043d\u0433 \u044f\u0437\u044b\u043a\u0435         if (($active_session.\u0421\u0422\u0410\u0422\u0423\u0421 -eq '\u0410\u043a\u0442\u0438\u0432\u043d\u043e') -or ($active_session.STATUS -eq 'Active')){             $id = $active_session.ID             }     }  Start-Process -FilePath \"mstsc\" -ArgumentList \"\/v:$ps \/shadow:$id \/control \/noconsentprompt\" -Credential $Cred -Wait -WindowStyle Maximized  }else {     $FormLabel4.Text = \"\u041a\u041e\u041c\u041f\u042c\u042e\u0422\u0415\u0420 \u041d\u0415 \u0414\u041e\u0421\u0422\u0423\u041f\u0415\u041d!\" }  }else {     $FormLabel4.Text = \"\u041b\u041e\u0413\u0418\u041d \u0418\u041b\u0418 \u041f\u0410\u0420\u041e\u041b\u042c \u041d\u0415 \u0412\u0415\u0420\u041d\u042b\u0415!\" }  }else {     $FormLabel4.Text = \"\u0412\u042b \u041d\u0415 \u0412\u042b\u0411\u0420\u0410\u041b\u0418 \u041a\u041e\u041c\u041f\u042c\u042e\u0422\u0415\u0420!\" }  }else {     $FormLabel4.Text = \"\u0412\u042b \u041d\u0415 \u0412\u0412\u0415\u041b\u0418 \u041f\u0410\u0420\u041e\u041b\u042c!\" }  })  $FormButton2 = New-Object System.Windows.Forms.Button $FormButton2.Location = New-Object System.Drawing.Size(10,440) $FormButton2.Size = New-Object System.Drawing.Size(200,30) $FormButton2.Text = \"\u0417\u0430\u043a\u0440\u044b\u0442\u044c\" $window_form.CancelButton = $FormButton3 $FormButton2.Add_Click({$window_form.Close();$window_form.Visible=$false})  $FormLabel4 = New-Object System.Windows.Forms.Label $FormLabel4.Text = \"\" $FormLabel4.Location = New-Object System.Drawing.Point(10,480) $FormLabel4.AutoSize = $true  $window_form.Controls.Add($FormButton) $window_form.Controls.Add($FormButton2) $window_form.Controls.Add($ListBox) $window_form.Controls.Add($FormTextBox1) $window_form.Controls.Add($FormTextBox2) $window_form.Controls.Add($FormLabel1) $window_form.Controls.Add($FormLabel2) $window_form.Controls.Add($FormLabel3) $window_form.Controls.Add($FormLabel4)  $window_form.Add_Shown({$FormTextBox1.Select()}) $window_form.Topmost = $true $window_form.MaximizeBox = $false  $result = $window_form.ShowDialog()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>Powershell \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0436\u0443\u0442\u043a\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. \u0415\u0441\u0442\u044c \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <a href=\"https:\/\/fixmypc.ru\/post\/konvertiruem-skripty-powershell-s-formata-ps1-v-exe-na-primerakh\/\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/a> \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 exe \u0444\u0430\u0439\u043b<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-372859","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=372859"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372859\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=372859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=372859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=372859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}