Skip to content

Commit 172043e

Browse files
fixed logs
1 parent 92bd8bd commit 172043e

File tree

3 files changed

+54
-36
lines changed

3 files changed

+54
-36
lines changed

ApplicationScanner.ps1

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ Function Get-ScriptPath {
114114
}
115115

116116
Function Get-SMSTSENV{
117-
param([switch]$LogPath,[switch]$NoWarning)
117+
param(
118+
[switch]$ReturnLogPath,
119+
[switch]$NoWarning
120+
)
118121

119122
Begin{
120123
## Get the name of this function
@@ -124,8 +127,6 @@ Function Get-SMSTSENV{
124127
try{
125128
# Create an object to access the task sequence environment
126129
$Script:tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
127-
#test if variables exist
128-
$tsenv.GetVariables() #| % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" }
129130
}
130131
catch{
131132
If(${CmdletName}){$prefix = "${CmdletName} ::" }Else{$prefix = "" }
@@ -136,25 +137,29 @@ Function Get-SMSTSENV{
136137
}
137138
Finally{
138139
#set global Logpath
139-
if ($tsenv){
140+
if ($Script:tsenv){
140141
#grab the progress UI
141142
$Script:TSProgressUi = New-Object -ComObject Microsoft.SMS.TSProgressUI
142143

143-
# Query the environment to get an existing variable
144-
# Set a variable for the task sequence log path
145-
#$UseLogPath = $tsenv.Value("LogPath")
146-
$UseLogPath = $tsenv.Value("_SMSTSLogPath")
147-
148144
# Convert all of the variables currently in the environment to PowerShell variables
149145
$tsenv.GetVariables() | % { Set-Variable -Name "$_" -Value "$($tsenv.Value($_))" }
146+
147+
# Query the environment to get an existing variable
148+
# Set a variable for the task sequence log path
149+
150+
#Something like: C:\MININT\SMSOSD\OSDLOGS
151+
#[string]$LogPath = $tsenv.Value("LogPath")
152+
#Somthing like C:\WINDOWS\CCM\Logs\SMSTSLog
153+
[string]$LogPath = $tsenv.Value("_SMSTSLogPath")
154+
150155
}
151156
Else{
152-
$UseLogPath = $env:Temp
157+
[string]$LogPath = $env:Temp
153158
}
154159
}
155160
}
156161
End{
157-
If($LogPath){return $UseLogPath}
162+
If($ReturnLogPath){return $LogPath}
158163
}
159164
}
160165

@@ -476,7 +481,7 @@ $scriptPath = Get-ScriptPath
476481
#build log name
477482
[string]$FileName = $scriptBaseName +'.log'
478483
#build global log fullpath
479-
$Global:LogFilePath = Join-Path (Get-SMSTSENV -LogPath -NoWarning) -ChildPath $FileName
484+
[string]$Global:LogFilePath = Join-Path (Get-SMSTSENV -ReturnLogPath -NoWarning) -ChildPath $FileName
480485
Write-Host "logging to file: $LogFilePath" -ForegroundColor Cyan
481486

482487
##*===========================================================================

Clean-ReferenceOS.ps1

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ Function Get-ScriptPath {
7575
}
7676

7777
Function Get-SMSTSENV{
78-
param([switch]$LogPath,[switch]$NoWarning)
78+
param(
79+
[switch]$ReturnLogPath,
80+
[switch]$NoWarning
81+
)
7982

8083
Begin{
8184
## Get the name of this function
@@ -85,8 +88,6 @@ Function Get-SMSTSENV{
8588
try{
8689
# Create an object to access the task sequence environment
8790
$Script:tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
88-
#test if variables exist
89-
$tsenv.GetVariables() #| % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" }
9091
}
9192
catch{
9293
If(${CmdletName}){$prefix = "${CmdletName} ::" }Else{$prefix = "" }
@@ -97,28 +98,33 @@ Function Get-SMSTSENV{
9798
}
9899
Finally{
99100
#set global Logpath
100-
if ($tsenv){
101+
if ($Script:tsenv){
101102
#grab the progress UI
102103
$Script:TSProgressUi = New-Object -ComObject Microsoft.SMS.TSProgressUI
103104

104-
# Query the environment to get an existing variable
105-
# Set a variable for the task sequence log path
106-
#$UseLogPath = $tsenv.Value("LogPath")
107-
$UseLogPath = $tsenv.Value("_SMSTSLogPath")
108-
109105
# Convert all of the variables currently in the environment to PowerShell variables
110106
$tsenv.GetVariables() | % { Set-Variable -Name "$_" -Value "$($tsenv.Value($_))" }
107+
108+
# Query the environment to get an existing variable
109+
# Set a variable for the task sequence log path
110+
111+
#Something like: C:\MININT\SMSOSD\OSDLOGS
112+
#[string]$LogPath = $tsenv.Value("LogPath")
113+
#Somthing like C:\WINDOWS\CCM\Logs\SMSTSLog
114+
[string]$LogPath = $tsenv.Value("_SMSTSLogPath")
115+
111116
}
112117
Else{
113-
$UseLogPath = $env:Temp
118+
[string]$LogPath = $env:Temp
114119
}
115120
}
116121
}
117122
End{
118-
If($LogPath){return $UseLogPath}
123+
If($ReturnLogPath){return $LogPath}
119124
}
120125
}
121126

127+
122128
Function Format-ElapsedTime($ts) {
123129
$elapsedTime = ""
124130
if ( $ts.Minutes -gt 0 ){$elapsedTime = [string]::Format( "{0:00} min. {1:00}.{2:00} sec.", $ts.Minutes, $ts.Seconds, $ts.Milliseconds / 10 );}
@@ -561,7 +567,7 @@ $scriptPath = Get-ScriptPath
561567
#build log name
562568
[string]$FileName = $scriptBaseName +'.log'
563569
#build global log fullpath
564-
$Global:LogFilePath = Join-Path (Get-SMSTSENV -LogPath -NoWarning) -ChildPath $FileName
570+
[string]$Global:LogFilePath = Join-Path (Get-SMSTSENV -ReturnLogPath -NoWarning) -ChildPath $FileName
565571
Write-Host "logging to file: $LogFilePath" -ForegroundColor Cyan
566572

567573
#variables

RemoveBuiltinApps.ps1

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ Function Get-ScriptPath {
6161
}
6262

6363
Function Get-SMSTSENV{
64-
param([switch]$LogPath,[switch]$NoWarning)
64+
param(
65+
[switch]$ReturnLogPath,
66+
[switch]$NoWarning
67+
)
6568

6669
Begin{
6770
## Get the name of this function
@@ -71,8 +74,6 @@ Function Get-SMSTSENV{
7174
try{
7275
# Create an object to access the task sequence environment
7376
$Script:tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
74-
#test if variables exist
75-
$tsenv.GetVariables() #| % { Write-Output "$ScriptName - $_ = $($tsenv.Value($_))" }
7677
}
7778
catch{
7879
If(${CmdletName}){$prefix = "${CmdletName} ::" }Else{$prefix = "" }
@@ -83,28 +84,34 @@ Function Get-SMSTSENV{
8384
}
8485
Finally{
8586
#set global Logpath
86-
if ($tsenv){
87+
if ($Script:tsenv){
8788
#grab the progress UI
8889
$Script:TSProgressUi = New-Object -ComObject Microsoft.SMS.TSProgressUI
8990

90-
# Query the environment to get an existing variable
91-
# Set a variable for the task sequence log path
92-
#$UseLogPath = $tsenv.Value("LogPath")
93-
$UseLogPath = $tsenv.Value("_SMSTSLogPath")
94-
9591
# Convert all of the variables currently in the environment to PowerShell variables
9692
$tsenv.GetVariables() | % { Set-Variable -Name "$_" -Value "$($tsenv.Value($_))" }
93+
94+
# Query the environment to get an existing variable
95+
# Set a variable for the task sequence log path
96+
97+
#Something like: C:\MININT\SMSOSD\OSDLOGS
98+
#[string]$LogPath = $tsenv.Value("LogPath")
99+
#Somthing like C:\WINDOWS\CCM\Logs\SMSTSLog
100+
[string]$LogPath = $tsenv.Value("_SMSTSLogPath")
101+
97102
}
98103
Else{
99-
$UseLogPath = $env:Temp
104+
[string]$LogPath = $env:Temp
100105
}
101106
}
102107
}
103108
End{
104-
If($LogPath){return $UseLogPath}
109+
If($ReturnLogPath){return $LogPath}
105110
}
106111
}
107112

113+
114+
108115
Function Format-ElapsedTime($ts) {
109116
$elapsedTime = ""
110117
if ( $ts.Minutes -gt 0 ){$elapsedTime = [string]::Format( "{0:00} min. {1:00}.{2:00} sec.", $ts.Minutes, $ts.Seconds, $ts.Milliseconds / 10 );}
@@ -289,7 +296,7 @@ $scriptPath = Get-ScriptPath
289296
#build log name
290297
[string]$FileName = $scriptBaseName +'.log'
291298
#build global log fullpath
292-
$Global:LogFilePath = Join-Path (Get-SMSTSENV -LogPath -NoWarning) -ChildPath $FileName
299+
[string]$Global:LogFilePath = Join-Path (Get-SMSTSENV -ReturnLogPath -NoWarning) -ChildPath $FileName
293300
Write-Host "logging to file: $LogFilePath" -ForegroundColor Cyan
294301

295302
##*===========================================================================

0 commit comments

Comments
 (0)