Skip to content

Commit 0c950f1

Browse files
updates
1 parent eb920f3 commit 0c950f1

File tree

4 files changed

+86
-24
lines changed

4 files changed

+86
-24
lines changed

.vscode/launch.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "PowerShell Launch Current File",
9+
"type": "PowerShell",
10+
"request": "launch",
11+
"script": "${file}",
12+
"args": [],
13+
"cwd": "${file}"
14+
},
15+
{
16+
"name": "PowerShell Launch Current File in Temporary Console",
17+
"type": "PowerShell",
18+
"request": "launch",
19+
"script": "${file}",
20+
"args": [],
21+
"cwd": "${file}",
22+
"createTemporaryIntegratedConsole": true
23+
},
24+
{
25+
"name": "PowerShell Launch Current File w/Args Prompt",
26+
"type": "PowerShell",
27+
"request": "launch",
28+
"script": "${file}",
29+
"args": [
30+
"${command:SpecifyScriptArgs}"
31+
],
32+
"cwd": "${file}"
33+
},
34+
{
35+
"name": "PowerShell Attach to Host Process",
36+
"type": "PowerShell",
37+
"request": "attach"
38+
},
39+
{
40+
"name": "PowerShell Interactive Session",
41+
"type": "PowerShell",
42+
"request": "launch",
43+
"cwd": ""
44+
},
45+
{
46+
"name": "PowerShell Attach Interactive Session Runspace",
47+
"type": "PowerShell",
48+
"request": "attach",
49+
"processId": "current"
50+
}
51+
]
52+
}

AppOptimizeAndConfig.ps1

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
2727
.NOTES
2828
Author: Richard Tracy
29-
Last Update: 05/30/2019
30-
Version: 1.1.5
29+
Last Update: 06/5/2019
30+
Version: 1.1.6
3131
Thanks to: unixuser011,W4RH4WK,TheVDIGuys,cluberti
3232
3333
.EXAMPLE
@@ -49,6 +49,7 @@
4949
https://github.com/cluberti/VDI/blob/master/ConfigAsVDI.ps1
5050
5151
.LOG
52+
1.1.6 - Jun 5, 2019 - Fixed Remove-AppxPackage for AllUsers
5253
1.1.5 - May 30, 2019 - defaulted reg type to dword if not specified, standarized registry keys captalizations
5354
1.1.4 - May 29, 2019 - fixed FOD issue and messages. fixed set-usersettings default users; fixed office detection
5455
resolved all VSC problems
@@ -1101,6 +1102,7 @@ If($RemoveAppxPackages)
11011102

11021103
$p = 1
11031104
$c = 0
1105+
$d = 0
11041106
# Loop through the list of appx packages
11051107
foreach ($App in $AppArrayList) {
11061108

@@ -1110,49 +1112,57 @@ If($RemoveAppxPackages)
11101112
}
11111113
else {
11121114
# Gather package names
1113-
$AppPackageFullName = Get-AppxPackage -Name $App.Name | Select-Object -ExpandProperty PackageFullName
1115+
$AppPackageDetails = Get-AppxPackage -AllUsers -Name $App.Name
11141116

1115-
$AppProvisioningPackageName = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -like $App.Name } | Select-Object -ExpandProperty PackageName
1117+
$AppProvisioningPackageName = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -like $AppPackageDetails.Name } | Select-Object -ExpandProperty PackageName
11161118

11171119
# Attempt to remove AppxPackage
1118-
if ($null -ne $AppPackageFullName) {
1119-
Show-ProgressStatus -Message ("Removing application package: {0}" -f $App.Name) -Step $p -MaxStep $AppArrayList.count
1120+
if ($null -ne $AppPackageDetails) {
1121+
Show-ProgressStatus -Message ("Removing application package: {0}" -f $AppPackageDetails.Name) -Step $p -MaxStep $AppArrayList.count
11201122

11211123
try {
1122-
Remove-AppxPackage -Package $AppPackageFullName -ErrorAction Stop | Out-Null
1124+
Remove-AppxPackage -AllUsers -Package $AppPackageDetails.PackageFullName -ErrorAction Stop | Out-Null
11231125

1124-
Write-LogEntry -Message ("Successfully removed application package: {0}" -f $App.Name) -Outhost
1126+
Write-LogEntry -Message ("Successfully removed application package: {0}" -f $AppPackageDetails.PackageFullName) -Outhost
11251127
$c++
11261128
}
11271129
catch [System.Exception] {
1128-
Write-LogEntry -Message ("Failed removing AppxPackage: {0}" -f $_.Message) -Severity 3 -Outhost
1130+
Write-LogEntry -Message ("Failed removing AppxPackage: {0}" -f $_) -Severity 3 -Outhost
1131+
}
1132+
Finally{
1133+
Write-LogEntry -Message ("--------------------------------------------------" ) -Outhost
11291134
}
11301135
}
11311136
else {
1132-
Write-LogEntry -Message ("Unable to locate AppxPackage for app: {0}" -f $App.Name) -Outhost
1137+
Write-LogEntry -Message ("Unable to locate AppxPackage for app: {0}" -f $AppPackageDetails.Name) -Outhost
11331138
}
11341139

11351140
# Attempt to remove AppxProvisioningPackage
1136-
if ($null -eq $AppProvisioningPackageName) {
1137-
Write-LogEntry -Message ("Removing application provisioning package: {0}" -f $AppProvisioningPackageName)
1141+
if ($null -ne $AppProvisioningPackageName) {
1142+
Write-LogEntry -Message ("Removing application PROVISIONED package: {0}" -f $AppProvisioningPackageName)
11381143
try {
11391144
Remove-AppxProvisionedPackage -PackageName $AppProvisioningPackageName -Online -ErrorAction Stop | Out-Null
1140-
Write-LogEntry -Message ("Successfully removed application provisioning package: {0}" -f $AppProvisioningPackageName) -Outhost
1145+
Write-LogEntry -Message ("Successfully removed application PROVISIONED package: {0}" -f $AppProvisioningPackageName) -Outhost
1146+
$d++
11411147
}
11421148
catch [System.Exception] {
1143-
Write-LogEntry -Message ("Failed removing Appx Provisioning Package: {0}" -f $_.Message) -Severity 3 -Outhost
1149+
Write-LogEntry -Message ("Failed removing Appx PROVISIONED Package: {0}" -f $_) -Severity 3 -Outhost
1150+
}
1151+
Finally{
1152+
Write-LogEntry -Message ("--------------------------------------------------" ) -Outhost
11441153
}
11451154
}
11461155
else {
1147-
Write-LogEntry -Message ("Unable to locate Appx Provisioning Package for app: {0}" -f $App.Name) -Outhost
1156+
Write-LogEntry -Message ("Unable to locate Appx PROVISIONED Package for app: {0}" -f $AppPackageDetails.Name) -Outhost
11481157
}
11491158

11501159
}
11511160

11521161
$p++
11531162
}
11541163

1155-
Write-LogEntry -Message ("Removed {0} built-in AppxPackage and AppxProvisioningPackage" -f $c) -Outhost
1164+
Write-LogEntry -Message ("Removed {0} All Users App Package's" -f $c) -Outhost
1165+
Write-LogEntry -Message ("Removed {0} built-in App PROVISIONED Package's" -f $d) -Outhost
11561166
}
11571167
Else{$stepCounter++}
11581168

Win10OptimizeAndConfig.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ If($EnableCredGuard)
26942694
Write-LogEntry "Successfully enabled Microsoft-Hyper-V-HyperVisor feature"
26952695
}
26962696
catch [System.Exception] {
2697-
Write-LogEntry ("An error occured when enabling Microsoft-Hyper-V-HyperVisor. Error: -f $_") -Severity 3
2697+
Write-LogEntry ("An error occured when enabling Microsoft-Hyper-V-HyperVisor. {0}" -f $_) -Severity 3
26982698
}
26992699

27002700
try {
@@ -2703,7 +2703,7 @@ If($EnableCredGuard)
27032703
Write-LogEntry "Successfully enabled IsolatedUserMode feature"
27042704
}
27052705
catch [System.Exception] {
2706-
Write-LogEntry ("An error occured when enabling IsolatedUserMode. Error: -f $_") -Severity 3
2706+
Write-LogEntry ("An error occured when enabling IsolatedUserMode. {0}" -f $_) -Severity 3
27072707
}
27082708
}
27092709

@@ -2718,7 +2718,7 @@ If($EnableCredGuard)
27182718
Set-SystemSetting -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity' -Name 'Enabled' -Type DWord -Value 1 -Force
27192719
Set-SystemSetting -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity' -Name 'Locked' -Type DWord -Value 0 -Force
27202720

2721-
Write-LogEntry "STIG Rule ID: SV-78089r7_rule :: Enabling Credential Guard on domain-joined systems"
2721+
Write-LogEntry "Enabling Credential Guard on domain-joined systems"
27222722
Set-SystemSetting -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' -Name 'LsaCfgFlags' -Type DWord -Value 1 -Force
27232723

27242724
$DeviceGuardProperty = Get-CimInstance –ClassName Win32_DeviceGuard –Namespace root\Microsoft\Windows\DeviceGuard

Win10STIGAndMitigations.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ If($ApplySTIGItems )
960960
Write-LogEntry "Successfully enabled Microsoft-Hyper-V-HyperVisor feature" -Outhost
961961
}
962962
catch [System.Exception] {
963-
Write-LogEntry ("An error occured when enabling Microsoft-Hyper-V-HyperVisor. Error: -f $_") -Severity 3 -Outhost
963+
Write-LogEntry ("An error occured when enabling Microsoft-Hyper-V-HyperVisor. {0}" -f $_) -Severity 3 -Outhost
964964
}
965965

966966
try {
@@ -969,7 +969,7 @@ If($ApplySTIGItems )
969969
Write-LogEntry "Successfully enabled IsolatedUserMode feature" -Outhost
970970
}
971971
catch [System.Exception] {
972-
Write-LogEntry ("An error occured when enabling IsolatedUserMode. Error: -f $_") -Severity 3 -Outhost
972+
Write-LogEntry ("An error occured when enabling IsolatedUserMode. {0}" -f $_) -Severity 3 -Outhost
973973
}
974974
}
975975

@@ -1010,7 +1010,7 @@ If($ApplySTIGItems )
10101010
'admin' {$value = 2;$label = "to Require Admin approval"}
10111011
default {$value = 1;$label = "to Warning Users"}
10121012
}
1013-
Show-ProgressStatus -Message "Configuring Smart Screen Filte :: Configuring Smart Screen Filter $label" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
1013+
Show-ProgressStatus -Message "Configuring Smart Screen Filter :: Configuring Smart Screen Filter $label" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
10141014
Set-SystemSetting -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\System' -Name 'EnableSmartScreen' -Type DWord -Value $value -Force -TryLGPO:$true
10151015
Set-SystemSetting -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\System' -Name 'ShellSmartScreenLevel' -Type String -Value "Block" -Force -TryLGPO:$true
10161016

@@ -1084,7 +1084,7 @@ If($ApplySTIGItems )
10841084
Show-ProgressStatus -Message "STIG Rule ID: SV-78287r1_rule :: Disabling LAN Manager hash of passwords for storage" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
10851085
Set-SystemSetting -Path 'HKLM:\System\CurrentControlSet\Control\Lsa' -Name 'NoLMHash' -Value 1 -Force
10861086

1087-
Show-ProgressStatus -Message "STIG Rule ID: SV-78291r1_rule :: Disabling NTLMv2 response only, and to refuse LM and NTLM" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
1087+
Show-ProgressStatus -Message "STIG Rule ID: SV-78291r1_rule :: Disabling NTLMv2 response only, and to refuse LM and NTLM" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
10881088
Set-SystemSetting -Path 'HKLM:\System\CurrentControlSet\Control\Lsa' -Name 'LmCompatibilityLevel' -Value 5 -Force
10891089

10901090
Show-ProgressStatus -Message "STIG Rule ID: SV-78293r1_rule :: Enabling LDAP client signing level" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
@@ -1102,7 +1102,7 @@ If($ApplySTIGItems )
11021102
Show-ProgressStatus -Message "STIG Rule ID: SV-78143r1_rule :: Disabling the ability to reset computer account password" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
11031103
Set-SystemSetting -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters' -Name 'DisablePasswordChange' -Value 1 -Force
11041104

1105-
Show-ProgressStatus -Message "STIG Rule ID: SV-78151r1_rule :: Configuring maximum age for machine account password to 30 days" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
1105+
Show-ProgressStatus -Message "STIG Rule ID: SV-78151r1_rule :: Configuring maximum age for machine account password to 30 days" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost
11061106
Set-SystemSetting -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters' -Name 'MaximumPasswordAge' -Value 30 -Force
11071107

11081108
Show-ProgressStatus -Message "STIG Rule ID: SV-78155r1_rule :: Configuring strong session key for machine account password" -Step ($stepCounter++) -MaxStep $script:Maxsteps -Outhost

0 commit comments

Comments
 (0)