Skip to content

Instantly share code, notes, and snippets.

@belotn
belotn / Change-ServiceOnFailure.ps1
Created March 26, 2014 16:06
Change Failure settings
get-xaserver |% {
gwmi Win32_Service -ComputerNAme $_.ServerName -Filter 'Name="cpsvc"' |% {
sc.Exe \\$($_.__SERVER) failure $($_.name) reset= 0 actions= restart/60000/restart/60000
}
}
@belotn
belotn / get-ServiceOnfailure.ps1
Created March 26, 2014 16:04
List failure option of a service
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
}}
import xml.etree.ElementTree as ET
import importlib
import sys
import os
if len(sys.argv) > 1:
xmlfile = sys.argv[1]
else:
xmlfile = os.path.normpath( os.getcwd() + "/backup.xml")
print(xmlfile)
@belotn
belotn / list_session.ps1
Last active January 3, 2016 05:49
list all session
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
@belotn
belotn / set-xaserverlicence.ps1
Created December 2, 2013 15:34
Forced Server to use Farme licence server configuration
get-xaserver | get-xaserverconfiguration |? {! $_.LicenseServerUseFarmSettings } |%{ set-xaserverconfiguration -ServerNAme $_.ServerName -LicenseServerUseFarmSettings $true }
@belotn
belotn / not_using_farmserverlicence.ps1
Created December 2, 2013 15:31
Get Servers Not using Farm Licence configuration
get-xaserver | get-xaserverconfiguration |? {! $_.LicenseServerUseFarmSettings } | select ServerName
@belotn
belotn / RemoteInstall.ps1
Last active December 26, 2015 18:59
Scheduled Remote Install with Citrix Scheduled Reboot
#########################################################
# FileName RemoteInstall.ps1 #
# Version 0.3 #
# Author Nicolas #
#########################################################
# ChangeLog #
# #
# Version 0.3 #
# Author Nicolas #
# Content Utilisation d'un fichier XML
@belotn
belotn / get-tsemapconfig.ps1
Created October 18, 2013 09:18
Get TSE Serevr Mapping Configuration
$TSEKey="SYSTEM\ControlSet001\Control\Terminal Server\WinStations\RDP-Tcp"
get-XAserver | %{
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$_.ServerName)
$copy = $_
$reg.OpenSubKey($TSEKey).getValueNames() |? { $_ -like 'fDisable*'} |% {
$copy | Add-member -Type NoteProperty -Name $_ -Value $reg.OpenSubKey($TSEKey).getValue($_)
}
$copy
} | select ServerName, fDisable*
@belotn
belotn / disabled-unusedgpoparts1L.ps1
Last active December 24, 2015 21:49
One liner Disable unused GPO settings (User, Computer, All) for GPO in an OU
Get-ADOrganizationalUnit -Filter 'OU -like "*Citrix*"' -SearchBase 'dc=fabrikam,dc=com' -Properties * |% { $_.gpLink -split ']' } |? { $_ -match '[0,2]$'} |% {(($_ -replace '\[','').split(';')[0]) -replace 'LDAP://',''} |% { get-adobject $_ -properties * } |sort -Unique DisplayName |% {if( $_.Flags -ne 3 ){if([bool]( gci "$($_.gPCFileSysPath)\User") -eq $false){if([bool](gci "$($_.gPCFileSysPath)\Machine") -eq $false){(get-gpo -Name $_.DisplayName).GpoStatus = "AllSettingsDisabled" }else{(get-gpo -Name $_.DisplayName).GpoStatus = "UserSettingsDisabled"}}else {if([bool](gci "$($_.gPCFileSysPath)\Machine") -eq $false){(get-gpo -Name $_.DisplayName).GpoStatus = "ComputerSettingsDisabled"}ELSE{}}}} }
@belotn
belotn / Disbale-GPOUnusedPart.ps1
Last active December 24, 2015 21:49
Desactivate GPO Parts without settings
Get-ADOrganizationalUnit -Filter 'OU -like "*Citrix*"' -SearchBase 'dc=fabrikam,dc=com' -Properties * |% {
$_.gpLink -split ']' } |? {
$_ -match '[0,2]$'} |% {
(($_ -replace '\[','').split(';')[0]) -replace 'LDAP://',''} |% {
get-adobject $_ -properties * } |
sort -Unique DisplayName |% {
if( $_.Flags -ne 3 ){
if([bool]( gci "$($_.gPCFileSysPath)\User") -eq $false){
if([bool](gci "$($_.gPCFileSysPath)\Machine") -eq $false){
(get-gpo -Name $_.DisplayName).GpoStatus = "AllSettingsDisabled"