7
7
Utilizes LGPO.exe to apply group policy item where neceassary.
8
8
Utilizes MDT/SCCM TaskSequence property control
9
9
Configurable using custom variables in MDT/SCCM
10
+
11
+ .INFO
12
+ Author: Richard Tracy
13
+ Email: richard.tracy@hotmail.com
14
+ Twitter: @rick2_1979
15
+ Website: www.powershellcrack.com
16
+ Last Update: 06/18/2019
17
+ Version: 1.1.6
18
+ Thanks to: unixuser011,W4RH4WK,TheVDIGuys,cluberti,JGSpiers
19
+
20
+ .DISCLOSURE
21
+ THE SCRIPT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. BY USING OR DISTRIBUTING THIS SCRIPT, YOU AGREE THAT IN NO EVENT
23
+ SHALL RICHARD TRACY OR ANY AFFILATES BE HELD LIABLE FOR ANY DAMAGES WHATSOEVER RESULTING FROM USING OR DISTRIBUTION OF THIS SCRIPT, INCLUDING,
24
+ WITHOUT LIMITATION, ANY SPECIAL, CONSEQUENTIAL, INCIDENTAL OR OTHER DIRECT OR INDIRECT DAMAGES. BACKUP UP ALL DATA BEFORE PROCEEDING.
10
25
11
26
.PARAM
12
27
'// Global Settings
24
39
CFG_RemoveAppxPackages
25
40
CFG_RemoveFODPackages
26
41
27
- . NOTES
28
- Author: Richard Tracy
29
- Last Update: 06/5/2019
30
- Version: 1.1.6
31
- Thanks to: unixuser011,W4RH4WK,TheVDIGuys,cluberti
32
-
33
42
. EXAMPLE
34
43
#Copy this to MDT CustomSettings.ini
35
44
Properties=CFG_DisableAppScript,CFG_UseLGPOForConfigs,LGPOPath,CFG_DisableOfficeAnimation,CFG_EnableIESoftwareRender,CFG_EnableLyncStartup,CFG_RemoveAppxPackages,CFG_RemoveFODPackages,CFG_RemoveUnusedPrinters
48
57
https://github.com/TheVDIGuys/W10_1803_VDI_Optimize
49
58
https://github.com/cluberti/VDI/blob/master/ConfigAsVDI.ps1
50
59
51
- .LOG
52
- 1.1.6 - Jun 5 , 2019 - Fixed Remove-AppxPackage for AllUsers
60
+ .CHANGE LOG
61
+ 1.1.6 - Jun 18 , 2019 - Added more info page, change Get-SMSTSENV warning to verbose message
53
62
1.1.5 - May 30, 2019 - defaulted reg type to dword if not specified, standarized registry keys captalizations
54
63
1.1.4 - May 29, 2019 - fixed FOD issue and messages. fixed set-usersettings default users; fixed office detection
55
64
resolved all VSC problems
@@ -102,24 +111,30 @@ Function Get-ScriptPath {
102
111
}
103
112
104
113
114
+
105
115
Function Get-SMSTSENV {
106
116
param (
107
- [switch ]$ReturnLogPath ,
108
- [switch ]$NoWarning
117
+ [switch ]$ReturnLogPath
109
118
)
110
119
111
120
Begin {
112
121
# # Get the name of this function
113
122
[string ]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
123
+
124
+ if (-not $PSBoundParameters.ContainsKey (' Verbose' )) {
125
+ $VerbosePreference = $PSCmdlet.SessionState.PSVariable.GetValue (' VerbosePreference' )
126
+ }
114
127
}
115
128
Process {
129
+ If (${CmdletName} ){$prefix = " ${CmdletName} ::" }Else {$prefix = " " }
130
+
116
131
try {
117
132
# Create an object to access the task sequence environment
118
- $Script :tsenv = New-Object - COMObject Microsoft.SMS.TSEnvironment
133
+ $Script :tsenv = New-Object - COMObject Microsoft.SMS.TSEnvironment
134
+ Write-Verbose (" {0}Task Sequence environment detected!" -f $prefix )
119
135
}
120
136
catch {
121
- If (${CmdletName} ){$prefix = " ${CmdletName} ::" }Else {$prefix = " " }
122
- If (! $NoWarning ){Write-Warning (" {0}Task Sequence environment not detected. Running in stand-alone mode" -f $prefix )}
137
+ Write-Verbose (" {0}Task Sequence environment not detected. Running in stand-alone mode" -f $prefix )
123
138
124
139
# set variable to null
125
140
$Script :tsenv = $null
@@ -129,7 +144,7 @@ Function Get-SMSTSENV{
129
144
if ($Script :tsenv ){
130
145
# grab the progress UI
131
146
$Script :TSProgressUi = New-Object - ComObject Microsoft.SMS.TSProgressUI
132
-
147
+
133
148
# Convert all of the variables currently in the environment to PowerShell variables
134
149
$tsenv.GetVariables () | ForEach-Object { Set-Variable - Name " $_ " - Value " $ ( $tsenv.Value ($_ )) " }
135
150
@@ -156,7 +171,8 @@ Function Get-SMSTSENV{
156
171
return $Script :tsenv
157
172
}
158
173
}
159
- }
174
+ }
175
+
160
176
161
177
162
178
Function Format-ElapsedTime ($ts ) {
@@ -945,7 +961,7 @@ Else{
945
961
# build log name
946
962
[string ]$FileName = $scriptBaseName + ' .log'
947
963
# build global log fullpath
948
- $Global :LogFilePath = Join-Path (Get-SMSTSENV - ReturnLogPath - NoWarning ) - ChildPath $FileName
964
+ $Global :LogFilePath = Join-Path (Get-SMSTSENV - ReturnLogPath - Verbose ) - ChildPath $FileName
949
965
Write-Host " logging to file: $LogFilePath " - ForegroundColor Cyan
950
966
951
967
@@ -1010,8 +1026,8 @@ If($OfficeInstalled){
1010
1026
}
1011
1027
1012
1028
# if running in a tasksequence; apply user settings to all user profiles (use ApplyTo param cmdlet Set-UserSettings )
1013
- If (Get-SMSTSENV - NoWarning ){$Global :ApplyToProfiles = ' AllUsers' }Else {$Global :ApplyToProfiles = ' CurrentUser' }
1014
- If ((Get-SMSTSENV - NoWarning ) -and -not ($psISE )){$Global :OutToHost = $false }Else {$Global :OutToHost = $true }
1029
+ If (Get-SMSTSENV ){$Global :ApplyToProfiles = ' AllUsers' }Else {$Global :ApplyToProfiles = ' CurrentUser' }
1030
+ If ((Get-SMSTSENV ) -and -not ($psISE )){$Global :OutToHost = $false }Else {$Global :OutToHost = $true }
1015
1031
1016
1032
# grab all Show-ProgressStatus commands in script and count them
1017
1033
$script :Maxsteps = ([System.Management.Automation.PsParser ]::Tokenize((Get-Content $scriptPath ), [ref ]$null ) | Where-Object { $_.Type -eq ' Command' -and $_.Content -eq ' Show-ProgressStatus' }).Count
0 commit comments