Manage Application in PowerShell

Some onliners to manager Application and server

Add n servers to an application

Limite one instance by user for an application

Re-activate all applications in a folder

Export all application in a folder

List Publication for an “Account”

Move Server to a new zone base on their IP addresses

List all server not using the farm “license Server” configuration

Force server to use the farm “License Server” configuration

get-xaserver | get-xaserverconfiguration |? {! $_.LicenseServerUseFarmSettings } |%{ set-xaserverconfiguration -ServerNAme $_.ServerName -LicenseServerUseFarmSettings $true }
;

Sort open sessions by inactivity

get-xaserver -FolderPAth $FOLDERPATH |% { 
	$sv = $_.ServerName; quser /SERVER:$($_.serverNAme) |% {
		$arrT = @( $_ -Split ' ' |? { $_ -ne ' '-and $_.length -gt 0 } );  
		new-object PSobject -property @{"Session" = $arrT[1]; "Inact" = $arrT[6]; "ServerName" = $sv}
	}
} |? { $_.Session -ne 'SESSION' } | sort Inact

Services Confiuration
List recovery settings of a service (failure)

get-xaserver  |% { 
       gwmi Win32_Service -ComputerNAme $_.ServerName -Filter 'Name="cpsvc"' } |select __SERVER,@{N="failure";E={ 
       (sc.exe \\$($_.__SERVER) qfailure $($_.Name) | select-string 'FAILURE') -ne $null
       }} 

Change recovery settings :

get-xaserver  |% { 
       gwmi Win32_Service -ComputerNAme $_.ServerName -Filter 'Name="cpsvc"' |% { 
                    sc.Exe \\$($_.__SERVER) failure $($_.name) reset= 0 actions= restart/60000/restart/60000 
             }
       } 

Change recovery settings for unconfigured server :

get-xaserver  |% { 
       gwmi Win32_Service -ComputerNAme $_.ServerName -Filter 'Name="cpsvc"' |% { 
             if(sc.exe \\$($_.__SERVER) qfailure $($_.name) | select-string 'FAILURE'){
                    "$($_.__SERVER) OK"
             }else{
                    sc.Exe \\$($_.__SERVER) failure $($_.name) reset= 86400 actions= restart/60000/restart/60000 
                    "$($_.SERVER) Set"
             }
       } 

Leave a Reply

Your email address will not be published. Required fields are marked *