Server IP : 180.180.241.3 / Your IP : 216.73.216.252 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Program Files/CA/arcserve Unified Data Protection/Engine/BIN/Appliance/ |
Upload File : |
write-host $(split-path $MyInvocation.MyCommand.Path -parent) cd $(split-path $MyInvocation.MyCommand.Path -parent) $debugpreference="Continue" $flog = $MyInvocation.MyCommand.Name+".log" if(test-path $flog){remove-item $flog -force -confirm:$false} $initerrorid = 0 $initerrorflag = ".\initerror.flag" if(test-path $initerrorflag){remove-item $initerrorflag -force -confirm:$false} mountvol /n $dsdrive="x" $ssddrive="y" $todod = $false function output-newline([string] $s){ write-host "$s"; $s | out-file $flog -append -encoding utf8 } #output-newline "INIT_STORAGE_START" function global:udp-create-partition{ param( [Parameter(Mandatory=$true)] [int]$disknumber, [Parameter(Mandatory=$true)] [string]$driveletter ) output-newline "Creating volume $driveletter..." #Start-Process c:\windows\system32\mountvol -argumentlist "/n" -windowstyle hidden #sleep 2 new-partition -disknumber $disknumber -usemaximumsize -driveletter $driveletter format-volume -driveletter $driveletter -filesystem ntfs -force -confirm:$false | write-debug output-newline "Volume $driveletter created." #Start-Process c:\windows\system32\mountvol -argumentlist "/e" -windowstyle hidden #sleep 1 } function global:udp-reset-ssd($ssd){ if($ssd.partitionstyle -notmatch "RAW"){ write-debug "Clearing disk..." clear-disk -number $ssd.number -confirm:$false -removedata -removeoem } sleep 1 } ###############test - remove this when release################## #udp-reset-storage output-newline "*****************************************"; output-newline "Starting storage device initialization..."; if((get-volume |?{$_.drivetype -match "cd-rom"}) -eq $null){write-debug "cd-rom does not exist"; }else{ write-debug "CD-ROM exists"; $cds = get-volume | ?{$_.drivetype -match "cd-rom"}; $cds |%{ $s = "CD-ROM drive letter {0}" -f $_.driveletter; write-debug $s; if(($_.driveletter -match $dsdrive) -or ($_.driveletter -match $ssddrive)){ output-newline "CD-ROM uses unexpected drive letter. Reassigning drive letter..." (gwmi Win32_cdromdrive).drive | %{$a = mountvol $_ /l;mountvol $_ /d;$a = $a.Trim();mountvol e: $a} } } write-debug "CD-ROM done." } $d = (get-partition -driveletter c).disknumber $pcount = (get-partition -disknumber $d).count write-debug "Partition count: $pcount" $ps = get-partition -disknumber $d $pcoff = ($ps |?{$_.driveletter -match "c"}).offset write-debug "C partition offset: $pcoff" ##### don't change the logic here - when a partition is deleted the disk object is changed and you need to get the new disk object again for($i=0;$i -lt $pcount;$i++){ $ps = get-partition -disknumber $d if($ps[$ps.count-1].offset -gt $pcoff){ write-debug $("Current partition offset: {0}" -f $ps[$ps.count-1].offset) remove-partition -disknumber $d -partitionnumber $ps[$ps.count-1].partitionnumber -confirm:$false; } } udp-create-partition $d $dsdrive $(new-item -path ($dsdrive+':\$$$arcserve.x') -itemtype file).Attributes="Hidden" if((get-volume|?{$_.driveletter -match $dsdrive}) -eq $null){ output-newline "[INIT_ERROR]Failed to create volume $dsdrive on disk $d where volume C exists. Please manually create volume $dsdrive on disk $d, then continue." -foregroundcolor red -backgroundcolor yellow; $initerrorid = 1; new-item -name $initerrorflag -force -itemtype file #pause; } $ssd = get-disk | ? {($_.Model -match "Micron") -or ($_.FriendlyName -match "Intel")}; if($ssd -eq $null){ ####search again based on size write-debug "Can not locate SSD by model info. Retrying by matching disk size." $ssd = get-disk |? {($_.size -gt 100000000000) -and ($_.size -lt 300000000000)} } if($ssd -eq $null){ output-newline "[INIT_ERROR]Can't locate SSD. Please manually create volume $ssddrive on it, then continue." -foregroundcolor red -backgroundcolor yellow; $initerrorid = 1; new-item -name $initerrorflag -force -itemtype file #pause; }else{ #take it online if it's offline $ssdnum = $ssd.number; if($ssd.operationalstatus -match "offline"){set-disk -number $ssdnum -isoffline $false; set-disk -number $ssdnum -IsReadOnly $false;} if($ssd.partitionstyle -notmatch "RAW"){ udp-reset-ssd $ssd; } $ssd = get-disk $ssdnum; "Now the SSD partition style: {0}" -f $ssd.partitionstyle | write-debug if($ssd.partitionstyle -match "RAW"){ output-newline "SSD partition style is RAW. Initializing..." initialize-disk -number $ssd.number -partitionstyle MBR -confirm:$false udp-create-partition $ssd.number $ssddrive $(new-item -path ($ssddrive+':\$$$arcserve.y') -itemtype file).Attributes="Hidden" }else{ output-newline "SSD un-initialization failed. Please manually create volume $ssddrive on it, then continue." -foregroundcolor red -backgroundcolor yellow; $initerrorid = 1; new-item -name $initerrorflag -force -itemtype file #pause; } } #output-newline "INIT_STORAGE_END" #stop-transcript output-newline "*****************************************"; output-newline ""; if($initerrorid -eq 0){ output-newline "Storage device initialization finished successfully."; }else{ output-newline "Storage device configuration failed. Please review error message above and correct the problems, then continue."; } return $initerrorid