Public/Disable-VirtualServer.ps1
Function Disable-VirtualServer { <# .SYNOPSIS Disable a virtual server #> [cmdletBinding()] param( $F5Session=$Script:F5Session, [Alias('VirtualServer')] [Parameter(Mandatory=$false,ParameterSetName='InputObject',ValueFromPipeline=$true)] [PSObject[]]$InputObject, [Alias("VirtualServerName")] [Parameter(Mandatory=$false,ParameterSetName='VirtualServerName',ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]]$Name='', [Alias('iApp')] [Parameter(Mandatory=$false,ParameterSetName='VirtualServerName',ValueFromPipelineByPropertyName=$true)] [string]$Application, [Parameter(Mandatory=$false,ParameterSetName='VirtualServerName',ValueFromPipelineByPropertyName=$true)] [string]$Partition ) process { $JSONBody = "{`"disabled`":true}" switch($PSCmdLet.ParameterSetName) { InputObject { if ($null -eq $InputObject) { $InputObject = Get-VirtualServer -F5Session $F5Session -Partition $Partition } foreach($vs in $InputObject) { $URI = $F5Session.GetLink($vs.selfLink) $FullPath = $vs.fullPath $null = Invoke-F5RestMethod -Method PATCH -Uri $URI -F5Session $F5Session -Body $JSONBody Get-VirtualServer -F5Session $F5Session -Name $FullPath } } VirtualServerName { foreach ($itemname in $Name) { Get-VirtualServer -F5Session $F5Session -Name $Name -Application $Application -Partition $Partition | Disable-VirtualServer -F5session $F5Session } } } } } |