logo

Powershell смена ключа Windows XP




yu_xuan

Powershell смена ключа Windows XP


Tags: windows powershell

Published : 3 months, 3 weeks ago (Thu, 07 Aug 2008 23:09:48 PDT)
Searched: powershell
http://yu-xuan.livejournal.com/25929.html  0 links
Related posts

В свете лицензирования локальных машин нужно сменить ключ ОС на правильный. Есть список компютеров в txt-файле. Вот таким скриптом победил это партийное задание.

#Менять ключ будем от имени доменного админа
$credentials = Get-Credential domain\admin

#Берем из списка по одному компьютеру и пингуем
Get-Content "C:\computers.txt" | ForEach-Object {

ping $_

#Если машина отвечает, то меняем через WMI ключик
#и пишем имя машины в файл success.txt
#Если не удается сменить ключ или компьютер не пингуется
#то пишем имя машины в файл problem.txt
if ($LastExitCode -eq 0)
    {
    $os = Get-WmiObject -Credential $credentials -ComputerName $_ win32_OperatingSystem
    if ($activation = Get-WmiObject -computer $_ -credential $credentials win32_WindowsProductActivation)
        {
        $activation.SetProductKey("ЗдесьНовыйКлючБезТиреИПробелов")
        Add-Content "C:\success.txt" "$_"
        }
    else
        {
        Add-Content "C:\problem.txt" "$_"
        }
    }
else
    {
    Add-Content "C:\problem.txt" "$_"
    }
}

yu_xuan

More results for "powershell"


This is cached version of livejournal post retrieved by LjSEEK on 2008-08-15 04:09:02 . Post may have changed since that time. Click here for actual post version. LjSEEK.COM is not affiliated with author of this post and is not responsible for its content.
These search terms have been highlighted: powershell
Disable Highlighting
yu_xuan's Search:
Get your own code!
Copyright © 2005,2006 ljseek.com This service is not affiliated with LiveJournal.com
Design by Steorra.com