-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-TaskTab.func.ps1
More file actions
185 lines (146 loc) · 5.08 KB
/
New-TaskTab.func.ps1
File metadata and controls
185 lines (146 loc) · 5.08 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
function Clear-CcmCache {
<#
.SYNOPSIS
Clears CcmClient cache by invoking CcmClient cleanup
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Clears CcmClient cache by invoking CcmClient cleanup
#>
Invoke-Command $cn {
$resman = New-Object -ComObject "UIResource.UIResourceMgr"
$cacheInfo = $resman.GetCacheInfo()
$cacheinfo.GetCacheElements() | foreach {$cacheInfo.DeleteCacheElement($_.CacheElementID)}
del "$env:SystemRoot\ccmcache\*" -Force -Recurse
$resman = New-Object -ComObject "UIResource.UIResourceMgr"
$cacheInfo = $resman.GetCacheInfo()
$cacheinfo.GetCacheElements() | foreach {$cacheInfo.DeleteCacheElement($_.CacheElementID)}
dir "$env:SystemRoot\ccmcache\"
}
}
function Invoke-CcmClientAction {
<#
.SYNOPSIS
Runs CcmClient management actions (policy download, application scan, etc)
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Runs CcmClient management actions (policy download, application scan, etc)
#>
Invoke-Command $cn {
enum CCMActions {
MachinePolicyRetrievalAndEval = '21'
MachinePolicyEval = '22'
DiscoveryDataCollection = '3'
SoftwareInventoryCycle = '2'
HardwareInventoryCycle = '1'
SoftwareUpdateScan = '113'
SoftwareUpdateDeploymentEval = '114'
SoftwareMeteringUsageReport = '31'
ApplicationDeploymentCycle = '121'
UserPolicyRetrieval = '26'
UserPolicyEval = '27'
WindowsInstallerSourceListUpdate = '32'
FileCollection = '10'
}
function Invoke-CCMClientAction {
param (
[parameter(Mandatory=$true)]
[CCMActions[]]$CCMAction
)
foreach ($action in $CCMAction) {
Invoke-WmiMethod -Namespace root\ccm -Class sms_client -Name TriggerSchedule "{00000000-0000-0000-0000-$($action.value__.ToString().PadLeft(12,'0'))}"
}
}
Invoke-CCMClientAction MachinePolicyRetrievalAndEval,HardwareInventoryCycle,SoftwareInventoryCycle,SoftwareUpdateScan,SoftwareUpdateDeploymentEval,ApplicationDeploymentCycle
}
}
function Get-BitsStatus {
<#
.SYNOPSIS
Get status of BITS downloads
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Get status of BITS downloads
#>
Invoke-Command $cn { bitsadmin /list /allusers }
}
function Get-CcmCache {
<#
.SYNOPSIS
Shows CcmCache location
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Shows CcmCache location
#>
Invoke-Command $cn { "$env:SystemRoot\ccmcache\" }
}
function Get-CcmCacheContent {
<#
.SYNOPSIS
Shows top level content of CcmCache
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Shows top level content of CcmCache
#>
Invoke-Command $cn { dir "$env:SystemRoot\ccmcache\" -Depth 1 }
}
function Get-MeteredStatus {
<#
.SYNOPSIS
Shows all WLAN metered connection status
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Shows all WLAN metered connection status
#>
Invoke-Command $cn {
[array]$WlanProfiles = netsh wlan show profiles |
? {$_ -match '^\s+All User Profile\s+: '} |
% {($_ -split ':',2)[1].trim()}
[array]$Connections = @()
$WlanProfiles | % {
$Cost = netsh wlan show profile name="$_" |
? {$_ -match '^\s+(Cost)\s+: '} |
% {($_ -split ':',2)[1].trim()}
$Connections += [PSCustomObject]@{Name=$_; Cost=$Cost}
}
$Connections
} | select Name,Cost
}
function Set-MeteredStatus {
<#
.SYNOPSIS
Sets the WLAN metered connection type
.FUNCTIONALITY
New-TaskTab.func
.DESCRIPTION
Sets the WLAN metered connection type
#>
param (
[parameter(Mandatory=$true)]
[string[]]$Name,
[parameter(Mandatory=$true,ParameterSetName='Metered')]
[switch]$Metered,
[parameter(Mandatory=$true,ParameterSetName='Unmetered')]
[switch]$Unmetered
)
if ($Metered) { $Cost = 'Fixed' }
elseif ($Unmetered) { $Cost = 'Unrestricted' }
else { return }
Invoke-Command $cn {
param ([string[]]$profile, [string]$cost)
$profile | % {
$Status = netsh wlan show profile name="$profile"
if ($Status -match "Profile `"$profile`" is not found on the system.") {
$Status
} else {
netsh wlan set profileparameter name="$profile" cost=$cost
}
}
} -Args $Name,$Cost
Get-MeteredStatus
}