<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/index.php?action=history&amp;feed=atom&amp;title=Powershell%3A_Ulvar_Petmanson%2C_BootUSB.ps1</id>
	<title>Powershell: Ulvar Petmanson, BootUSB.ps1 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/index.php?action=history&amp;feed=atom&amp;title=Powershell%3A_Ulvar_Petmanson%2C_BootUSB.ps1"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Powershell:_Ulvar_Petmanson,_BootUSB.ps1&amp;action=history"/>
	<updated>2026-05-06T08:32:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Powershell:_Ulvar_Petmanson,_BootUSB.ps1&amp;diff=45761&amp;oldid=prev</id>
		<title>Upetmans at 22:14, 26 January 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Powershell:_Ulvar_Petmanson,_BootUSB.ps1&amp;diff=45761&amp;oldid=prev"/>
		<updated>2012-01-26T22:14:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:14, 27 January 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;source lang=&quot;powershell&quot;&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;#&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.Synopsis&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;.Synopsis&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key ico_mediawiki-ITK_:diff:1.41:old-45760:rev-45761:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Upetmans</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Powershell:_Ulvar_Petmanson,_BootUSB.ps1&amp;diff=45760&amp;oldid=prev</id>
		<title>Upetmans: Created page with &#039;&lt;# .Synopsis   Teeb Windows 7 või Windows 2008 paigaldamise USB pulga. .Description   1. Otsib arvuti DVD seadmetest üles kõik sobivad Windows&#039;i installi plaadid ja USB kettad…&#039;</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Powershell:_Ulvar_Petmanson,_BootUSB.ps1&amp;diff=45760&amp;oldid=prev"/>
		<updated>2012-01-26T22:12:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;# .Synopsis   Teeb Windows 7 või Windows 2008 paigaldamise USB pulga. .Description   1. Otsib arvuti DVD seadmetest üles kõik sobivad Windows&amp;#039;i installi plaadid ja USB kettad…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;#&lt;br /&gt;
.Synopsis&lt;br /&gt;
  Teeb Windows 7 või Windows 2008 paigaldamise USB pulga.&lt;br /&gt;
.Description&lt;br /&gt;
  1. Otsib arvuti DVD seadmetest üles kõik sobivad Windows&amp;#039;i installi plaadid ja USB kettad, ning moodustab nendest sobivad paarid&lt;br /&gt;
  2. Annab võimalusel kasutajale valida, milliselt plaadilt, millisele USB kettale Windows&amp;#039;i paigaldusfailid kopeeritakse.&lt;br /&gt;
  3. Kui valitud USB ketas pole tühi, küsib kasutajalt nõusolekut ketta tühjendamiseks, seejärel teeb USB ketta buutivaks.&lt;br /&gt;
  4. Kopeerib Windowsi paigaldusfailid USB kettale. &lt;br /&gt;
#&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$SourcesDir = &amp;quot;\sources\&amp;quot;&lt;br /&gt;
$InstallFileToCheck = &amp;quot;install.wim&amp;quot;&lt;br /&gt;
$Kettad = (Get-WmiObject win32_logicaldisk -filter &amp;#039;DriveType=5 and Access&amp;gt;0&amp;#039;)&lt;br /&gt;
$USBKettad = (Get-WmiObject win32_logicaldisk -filter &amp;#039;DriveType=2&amp;#039;)&lt;br /&gt;
$UusKettad = @()&lt;br /&gt;
$KetastePaarid =@()&lt;br /&gt;
$i = 0&lt;br /&gt;
&lt;br /&gt;
Function Select-Item &lt;br /&gt;
{    &amp;lt;# &lt;br /&gt;
     &lt;br /&gt;
     From: http://blogs.technet.com/b/jamesone/archive/2009/06/24/how-to-get-user-input-more-nicely-in-powershell.aspx&lt;br /&gt;
     &lt;br /&gt;
     .Synopsis        Allows the user to select simple items, returns a number to indicate the selected item. &lt;br /&gt;
    .Description &lt;br /&gt;
        Produces a list on the screen with a caption followed by a message, the options are then        displayed one after the other, and the user can one. &lt;br /&gt;
          Note that help text is not supported in this version. &lt;br /&gt;
    .Example &lt;br /&gt;
        PS&amp;gt; select-item -Caption &amp;quot;Configuring RemoteDesktop&amp;quot; -Message &amp;quot;Do you want to: &amp;quot; -choice &amp;quot;&amp;amp;Disable Remote Desktop&amp;quot;,           &amp;quot;&amp;amp;Enable Remote Desktop&amp;quot;,&amp;quot;&amp;amp;Cancel&amp;quot;  -default 1       Will display the following &lt;br /&gt;
          Configuring RemoteDesktop           Do you want to:           [D] Disable Remote Desktop  [E] Enable Remote Desktop  [C] Cancel  [?] Help (default is &amp;quot;E&amp;quot;): &lt;br /&gt;
    .Parameter Choicelist &lt;br /&gt;
        An array of strings, each one is possible choice. The hot key in each choice must be prefixed with an &amp;amp; sign &lt;br /&gt;
    .Parameter Default &lt;br /&gt;
        The zero based item in the array which will be the default choice if the user hits enter. &lt;br /&gt;
    .Parameter Caption &lt;br /&gt;
        The First line of text displayed &lt;br /&gt;
     .Parameter Message &lt;br /&gt;
        The Second line of text displayed     #&amp;gt; &lt;br /&gt;
Param(   [String[]]$choiceList, &lt;br /&gt;
         [String]$Caption=&amp;quot;Palun vali&amp;quot;, &lt;br /&gt;
         [String]$Message=&amp;quot;Valikud on järgnevad&amp;quot;, &lt;br /&gt;
         [int]$default=0 &lt;br /&gt;
      ) &lt;br /&gt;
   $choicedesc = New-Object System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription] &lt;br /&gt;
   $choiceList | foreach  { $choicedesc.Add((New-Object &amp;quot;System.Management.Automation.Host.ChoiceDescription&amp;quot; -ArgumentList $_))} &lt;br /&gt;
   $Host.ui.PromptForChoice($caption, $message, $choicedesc, $default) &lt;br /&gt;
}  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
foreach ($Ketas in $Kettad)&lt;br /&gt;
{&lt;br /&gt;
  $Usable = Test-Path ($Ketas.DeviceID + $SourcesDir + $InstallFileToCheck)&lt;br /&gt;
  if ($Usable) {&lt;br /&gt;
      $UusKetas = New-Object PSobject -Property @{&lt;br /&gt;
          DeviceID = $Ketas.DeviceID&lt;br /&gt;
          DriveType = $Ketas.DriveType&lt;br /&gt;
          ProviderName = $Ketas.ProviderName&lt;br /&gt;
          FreeSpace = $Ketas.FreeSpace&lt;br /&gt;
          Size = $Ketas.Size&lt;br /&gt;
          VolumeName = $Ketas.VolumeName&lt;br /&gt;
          Usable = $Usable&lt;br /&gt;
          Jrk = $i&lt;br /&gt;
          }&lt;br /&gt;
      $i++&lt;br /&gt;
  $UusKettad += $UusKetas&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ( $UusKettad.Count -lt 1 ) {&lt;br /&gt;
  echo &amp;quot;Windowsi installi plaati ei leitud!&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$i = 0&lt;br /&gt;
foreach ($Ketas in $UusKettad)&lt;br /&gt;
{&lt;br /&gt;
  foreach ($USBKetas in $USBKettad)&lt;br /&gt;
  {&lt;br /&gt;
  $Ketas.Size&lt;br /&gt;
  $USBKetas.Size&lt;br /&gt;
    if ($Ketas.Size -lt $USBKetas.Size) {&lt;br /&gt;
      $KetastePaar = New-Object PSobject -Property @{&lt;br /&gt;
          Source = $Ketas.DeviceID&lt;br /&gt;
          SourceVolumeName = $Ketas.VolumeName&lt;br /&gt;
          Destination = $USBKetas.DeviceID&lt;br /&gt;
          DestinationVolumeName = $USBKetas.VolumeName&lt;br /&gt;
          Jrk = $i&lt;br /&gt;
          }&lt;br /&gt;
    if ( ($KetastePaar.DestinationVolumeName).Length -eq 0) { $KetastePaar.DestinationVolumeName = &amp;quot;Nimetu&amp;quot; }&lt;br /&gt;
      $i++&lt;br /&gt;
      $KetastePaarid += $KetastePaar&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$KetastePaarid&lt;br /&gt;
if ( $Ketastepaarid.Count -eq 0 ) {&lt;br /&gt;
  echo &amp;quot;Pole ühtki sobivat ketaste paari!&amp;quot;&lt;br /&gt;
  exit&lt;br /&gt;
}&lt;br /&gt;
$i = 0&lt;br /&gt;
$Valikud = @()&lt;br /&gt;
&lt;br /&gt;
foreach ($KetastePaar in $KetastePaarid)&lt;br /&gt;
{&lt;br /&gt;
  $Valikud += &amp;quot;&amp;amp;&amp;quot; + $i + &amp;quot;.&amp;quot; + $KetastePaar.Source + &amp;quot; (&amp;quot; + $KetastePaar.SourceVolumeName + &amp;quot;) &amp;quot; + &amp;quot; -&amp;gt; &amp;quot; + $KetastePaar.Destination + &amp;quot; (&amp;quot; + $KetastePaar.DestinationVolumeName + &amp;quot;) &amp;quot;&lt;br /&gt;
  $i++&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$Valikjrk = Select-Item -Choice $Valikud&lt;br /&gt;
&lt;br /&gt;
$KetastePaarid&lt;br /&gt;
&lt;br /&gt;
foreach ( $KetastePaar in $KetastePaarid)&lt;br /&gt;
{&lt;br /&gt;
 if ( $KetastePaar.Jrk -eq $Valikjrk)&lt;br /&gt;
   {&lt;br /&gt;
     $KetastePaar.DestinationVolumeName&lt;br /&gt;
     $Source = $KetastePaar.Source&lt;br /&gt;
     $Destination = $KetastePaar.Destination&lt;br /&gt;
     $DestinationVolumeName = $KetastePaar.DestinationVolumeName&lt;br /&gt;
     &lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$Source&lt;br /&gt;
$Destination&lt;br /&gt;
&lt;br /&gt;
if ( @(Get-ChildItem $Destination -force).Count -gt 0)&lt;br /&gt;
{&lt;br /&gt;
   $a = new-object -comobject wscript.shell &lt;br /&gt;
  $intAnswer = $a.popup(&amp;quot;Pulk $Destination ( $DestinationVolumeName ) ei ole tühi, kas võib tühjaks teha?&amp;quot;,0,&amp;quot;Teeme tühjaks?&amp;quot;,4)&lt;br /&gt;
&lt;br /&gt;
  If (!($intAnswer -eq 6)) { &lt;br /&gt;
    echo &amp;quot;Nägemist!&amp;quot;&lt;br /&gt;
    exit&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$command= @&amp;quot;&lt;br /&gt;
select volume $Destination&lt;br /&gt;
clean&lt;br /&gt;
create partition primary&lt;br /&gt;
select partition 1&lt;br /&gt;
active&lt;br /&gt;
format fs=fat32 quick&lt;br /&gt;
exit&lt;br /&gt;
&amp;quot;@&lt;br /&gt;
&lt;br /&gt;
$command | Diskpart&lt;br /&gt;
&lt;br /&gt;
&amp;amp; &amp;quot;$Source\Boot\BOOTSECT.EXE&amp;quot; /NT60 $Destination&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Kopeerin failid pulgale.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Copy-Item $Source\* $Destination\ -Recurse&lt;/div&gt;</summary>
		<author><name>Upetmans</name></author>
	</entry>
</feed>