-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun-CitrixDelprof.ps1
58 lines (56 loc) · 2.55 KB
/
Run-CitrixDelprof.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function Run-CitrixDelprof {
<#
.Synopsis
Deletes all or targeted local profiles on citrixhosts.
.DESCRIPTION
Uses the ImportExcel module to import an excel sheet that has all citrix host
server information broken down by delivery group. You use the -DeliveryGroup parameter
to select the delivery group you want to target. You can also use the
.PARAMETER ComputerName
The name of the register to query. Accepts multiple values
and accepts pipeline input
.PARAMETER IPAddress
The IP Address to query. Accepts multiple values but not pipeline input.
.PARAMETER ShowProgress
displays a progress bar showing current operations and percent complete.
Percentage will be inaccurate when piping computer names into the command.
.EXAMPLE
.EXAMPLE
.EXAMPLE
.LINK
#>
[Cmdletbinding()]
param (
[parameter(mandatory=$True)]
[ValidateSet('Group1','Group2','Group3')]
[String[]]$DeliveryGroup
)
BEGIN {
$CitrixHostsExcelLocation = '\\NetworkFolder\Powershell\Excel\CitrixHosts.xlsx'
$CitrixHosts = Import-Excel -Path $CitrixHostsExcelLocation
$DeliveryGroupCount = $DeliveryGroup.Count
If ($DeliveryGroupCount -eq 1) {
$FilteredDeliveryGroup = $CitrixHosts | Where Group -Match $DeliveryGroup
} elseif ($DeliveryGroupCount -eq 2) {
$FilteredDeliveryGroup = $CitrixHosts | Where {$_.Group -Match $DeliveryGroup[0] -or $_.Group -match $DeliveryGroup[1]}
} elseif ($DeliveryGroupCount -eq 3) {
$FilteredDeliveryGroup = $CitrixHosts | Where {$_.Group -Match $DeliveryGroup[0] -or $_.Group -match $DeliveryGroup[1] -or $_.Group -match $DeliveryGroup[2]}
} Else { Write-Host "Invalid Entry. Try running the command again." }
Write-Output "You will be running Delprof2 on each of the following hosts."
Write-Output " "
$FilteredDeliveryGroup.Hostname
Write-Output " "
$Answer = Read-Host -Prompt "Would you like to continue? Yes or No"
}
PROCESS {
if ($Answer -eq 'Yes') {
Foreach ($Server in $FilteredDeliveryGroup) {
$Args1 = "[Console]::Title='$($Server.Hostname)';[console]::WindowHeight='10';[Console]::WindowWidth='90';CLS"
$Args2 = "\\NetworkFolder\scripts\DelProf2.exe /c:$($Server.IPAddress) /l;Pause"
Start-Process Powershell -ArgumentList "$Args1;$Args2"
}
} else {
Write-Host "Ending Command."
}
}
}