Compare commits
	
		
			2 Commits
		
	
	
		
			f8d0c1cdde
			...
			93cadce4fe
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 93cadce4fe | |||
| 4d7400ed43 | 
							
								
								
									
										51
									
								
								scripts/Remove-Resources.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								scripts/Remove-Resources.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| [CmdletBinding()] | ||||
| Param( | ||||
|     [Parameter(Mandatory)] | ||||
|     [string]$VMName, | ||||
|     [Parameter(Mandatory)] | ||||
|     [string]$VSphereFQDN, | ||||
|     [Parameter(Mandatory)] | ||||
|     [string]$VSphereUsername, | ||||
|     [Parameter(Mandatory)] | ||||
|     [string]$VSpherePassword | ||||
| ) | ||||
|  | ||||
| $PowerCliConfigurationSplat = @{ | ||||
|     Scope                    = 'User' | ||||
|     ParticipateInCEIP        = $False | ||||
|     Confirm                  = $False | ||||
|     InvalidCertificateAction = 'Ignore' | ||||
| } | ||||
| Set-PowerCLIConfiguration @PowerCliConfigurationSplat | Out-Null | ||||
|  | ||||
| $ConnectVIServerSplat = @{ | ||||
|     Server        = $VSphereFQDN | ||||
|     User          = "$VSphereUsername" | ||||
|     Password      = "$VSpherePassword" | ||||
|     WarningAction = 'SilentlyContinue' | ||||
| } | ||||
| Connect-VIServer @ConnectVIServerSplat | Out-Null | ||||
|  | ||||
| $GetVMSplat = @{ | ||||
|     Name        = "*$($VMName)*" | ||||
|     ErrorAction = 'SilentlyContinue' | ||||
| } | ||||
| If ([boolean](Get-VM @GetVMSplat)) { | ||||
|     $RemoveVMSplat = @{ | ||||
|         VM                       = Get-VM @GetVMSplat | ||||
|         DeletePermanently        = $True | ||||
|         Confirm                  = $False | ||||
|         ErrorAction              = 'SilentlyContinue' | ||||
|     } | ||||
|     Remove-VM @RemoveVMSplat | ||||
| } | ||||
|  | ||||
| Disconnect-VIServer * -Confirm:$False | ||||
|  | ||||
| $RemoveItemSplat = @{ | ||||
|     Path    = "/scratch/*" | ||||
|     Recurse = $True | ||||
|     Force   = $True | ||||
|     Confirm = $False | ||||
| } | ||||
| Remove-Item @RemoveItemSplat | ||||
		Reference in New Issue
	
	Block a user