Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-PSSnapin XenServerPSSnapin
- $strSrv = Read-Host "XenServer"
- Get-Credential | Connect-XenServer -Server $strSrv
- [psobject]$sr = Get-XenServer:SR | Where-Object{$_.content_type -eq "iso" -and $_.type -ne "udev" -and $_.name_label -ne "XenServer Tools"}
- "There are currently {0} ISO repositories." -f $sr.Count
- foreach($tsr in $sr)
- {
- $csr = $tsr.name_label
- $destroy = Read-Host "Destroy the $csr SR? [y|n]"
- if($destroy -eq "y")
- {
- foreach($i in $tsr.PBDs){Invoke-XenServer:PBD.Unplug $i}
- Invoke-XenServer:SR.Forget -SR $tsr.name_label
- }
- }
- $destroy = $null
- $destroy = Read-Host "Create New ISO SR? [y|n]"
- if($destroy -eq "y")
- {
- $srname = Read-Host "SR Name"
- $srdesc = Read-Host "SR Description"
- $srpath = Read-Host "SR Path (//host/path/dst)"
- $creds = Read-Host "Specify credentials? [y|n]"
- $uuid = (Get-XenServer:Host).uuid
- if($creds -eq "n" -or $creds -eq $null){
- $config = @{"location" = "$srpath"}
- Create-XenServer:SR -Host $uuid -NameLabel $srname -NameDescription $srdesc -Type iso -ContentType iso -DeviceConfig $config
- }elseif($creds -eq "y"){
- $creds = Get-Credential
- $config = @{"location" = "$srpath"; "username" = $creds.UserName; "cifspassword" = $creds.GetNetworkCredential().Password}
- Create-XenServer:SR -Host $uuid -NameLabel $srname -NameDescription $srdesc -Type "iso" -ContentType "iso" -DeviceConfig $config
- }
- }
- "Press any key to exit..."
- $exit = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement