{"id":244,"date":"2012-02-29T14:24:36","date_gmt":"2012-02-29T10:24:36","guid":{"rendered":"http:\/\/samara-it.ru\/?p=244"},"modified":"2012-03-01T19:46:10","modified_gmt":"2012-03-01T15:46:10","slug":"%d0%92%d1%8b%d0%bf%d0%be%d0%bb%d0%bd%d0%b5%d0%bd%d0%b8%d0%b5-%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82%d0%be%d0%b2-%d0%bd%d0%b0-%d1%83%d0%b4%d0%b0%d0%bb%d0%b5%d0%bd%d0%bd%d1%8b%d1%85-%d1%81%d0%b5%d1%80","status":"publish","type":"post","link":"https:\/\/www.samara-it.ru\/?p=244","title":{"rendered":"\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445"},"content":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"http:\/\/samara-it.ru\/?p=187\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445. \u0412 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043e\u0434\u043d\u0430 \u043f\u0430\u0440\u0430 \u043b\u043e\u0433\u0438\u043d\\\u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0430\u0440\u043e\u043b\u0438 \u0434\u0430 \u0438 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043e\u043d\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u0442\u0438? \u0412\u044b\u0445\u043e\u0434\u043e\u0432 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u044f \u043d\u0430\u0448\u0435\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre lang=\"powershell\" escaped=\"true\">$credential=Get-Credential\r\n$credential.Password | ConvertFrom-SecureString<\/pre>\n<p>\u0438\u043b\u0438<\/p>\n<pre lang=\"powershell\" escaped=\"true\">$out = \"c:\\password.txt\"\r\n$credential=Get-Credential\r\n$credential.Password | ConvertFrom-SecureString | Add-Content $out<\/pre>\n<p>\u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 (\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0432 \u043e\u0442\u043a\u0440\u044b\u0432\u0448\u0438\u043c\u0441\u044f \u043e\u043a\u043d\u0435 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u043b\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d (\u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442) \u0438\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b (\u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442). \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0447\u0442\u043e \u0438\u043d\u043e\u0439 \u043a\u0430\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0432\u0432\u0435\u043b\u0438. \u0412\u043e\u0442 \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b \u0438 \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u00a0server_all.txt \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c:<\/p>\n<pre lang=\"dos\">Administrator;01000000d08c9ddf011.....7adb2;server1,server2\r\nAdministrator;01000000d08c9ddf011.....8fa35;server3,server7,server10,srv2\r\nAdministrator;01000000d08c9ddf011.....dea73;srv1<\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u044f &#171;\u043e\u0431\u0440\u0435\u0437\u0430\u043b&#187; \u043f\u0430\u0440\u043e\u043b\u044c, \u0442.\u043a. \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u043e\u043b\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043f\u0430\u0440\u043e\u043b\u0435\u043c \u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043b \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u044d\u0442\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445. \u0414\u0430\u043b\u0435\u0435 \u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u044d\u0442\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445.<\/p>\n<pre lang=\"powershell\" escaped=\"true\">cls\r\n\r\n$srv = Get-Content \"x:\\[path]\\server_all.txt\";\r\n\r\n# \u0421\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445\r\n$script_txt = \"Get-Process exp*\"\r\n# \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u0432 \"ScriptBlock\"\r\n$script = $executioncontext.invokecommand.NewScriptBlock($script_txt)\r\n\r\n#\u0417\u0430\u0431\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438\r\nforeach ($var in $srv) {\r\n\r\n\t# \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 #- \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439.\r\n\t# \u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443\r\n\tif (($var -notmatch \"#\") -and ($var.Length -ne 0)){\r\n\r\n\t\t# \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443\r\n\t\t$tmp = $var -split \";\"\r\n\r\n\t\t# \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043f\u0430\u0440\u043e\u043b\u044c\r\n\t\t$pass = $tmp[1] | ConvertTo-SecureString\r\n\t\t$cred = New-Object System.Management.Automation.PSCredential $tmp[0],$pass\r\n\r\n\t\t$s = $tmp[2] -split \",\"\r\n\r\n\t\t# \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e\r\n\t\t$session = New-PSSession -ComputerName $s -Credential $cred\r\n\r\n\t\t# \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 (\u043d\u0430\u0439\u0434\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \"explorer\")\r\n\t\t$result = Invoke-Command -Session $session -ScriptBlock $script\r\n\r\n\t\t# \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\r\n\t\tfor ($i=0; $i -lt $result.Count; $i++){\r\n\t\t\tWrite-Host $result[$i].PSComputerName,\"`t\",$result[$i].Name\r\n\t\t}\r\n\r\n\t\t#\u0412\u044b\u0445\u043e\u0434\u0438\u043c \u0438\u0437 \u0441\u0435\u0441\u0441\u0438\u0438.\r\n\t\tRemove-PSSession -Session $session\r\n\r\n\t}\r\n}<\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<pre lang=\"dos\">server1   explorer\r\nserver2   explorer\r\nserver3   explorer\r\nserver7   explorer\r\nserver10   explorer\r\nsrv2   explorer\r\nsrv1   explorer<\/pre>\n<p>\u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0432\u0441\u0435.<br \/>\n\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u0447\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0442\u0430\u043a \u044d\u0442\u043e \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 (\u0438\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u043e\u0439 \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e), \u0442\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0442.\u043a. \u043f\u0430\u0440\u043e\u043b\u0438 &#171;\u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f&#187; \u043a \u0443\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0443. \u0418 \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u043f\u043b\u044e\u0441!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445. \u0412 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043e\u0434\u043d\u0430 \u043f\u0430\u0440\u0430 \u043b\u043e\u0433\u0438\u043d\\\u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u0410 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0430\u0440\u043e\u043b\u0438 \u0434\u0430 \u0438 \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043e\u043d\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u0442\u0438? \u0412\u044b\u0445\u043e\u0434\u043e\u0432 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.samara-it.ru\/?p=244\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":306,"comment_status":"close","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,1],"tags":[11,10],"class_list":["post-244","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","category-win","tag-posh","tag-powershell-2"],"_links":{"self":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=244"}],"version-history":[{"count":30,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":309,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions\/309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=\/wp\/v2\/media\/306"}],"wp:attachment":[{"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samara-it.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}