<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; PowerShell вывод имен операционных систем]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=11156</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=11156&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «PowerShell вывод имен операционных систем».]]></description>
		<lastBuildDate>Fri, 18 Dec 2015 14:53:06 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[PowerShell вывод имен операционных систем]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=99750#p99750</link>
			<description><![CDATA[<p>Добрый вечер. Помогите разобраться (PowerShell стал изучать не давно).</p><p>По заданию в файле Spisok.txt находится список имен компьютеров, нужно их опросить и вывести название операционных систем. <br /></p><div class="codebox"><pre><code>
    ..........................
    $ishod = &quot;Microsoft Windows 7 Профессиональная&quot;  
    try{   
            $ser = Get-Content C:\t\Spisok.txt
            $os  = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $ser
            foreach ($sProperties in $os)
            {  
                $val=$sProperties.Caption         
                $val = $val -replace $val, $ishod #имя ОС
                if($val -eq $ishod)
                {      
                    Write-Host $sProperties.__SERVER &quot;-&quot; $val -ForegroundColor Green
                }   
            }
       }
    catch [System.UnauthorizedAccessException]
    {
          Write-Host &quot;Ошибка&quot;
    }</code></pre></div><p>Он работает (без try catch) только в том случае, если компьютер при проверки включен.<br />А как это обойти???</p><p>Выводит ошибку:<br />Get-WmiObject : Сервер RPC недоступен. (Исключение из HRESULT: 0x800706BA)<br />строка:26 знак:22<br />+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$os&nbsp; = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $s ...<br />+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />&nbsp; &nbsp; + CategoryInfo&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : InvalidOperation: (:) [Get-WmiObject], COMException<br />&nbsp; &nbsp; + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand</p>]]></description>
			<author><![CDATA[null@example.com (Dark_Evans)]]></author>
			<pubDate>Fri, 18 Dec 2015 14:53:06 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=99750#p99750</guid>
		</item>
	</channel>
</rss>
