StevensNet.com

...Because someone's gotta tell the story...

Blogs

To return to the main Blog List, click Full Blog Listing.

Tags

PowerShell
SCCM

PowerShell to check if you are running in a Task Sequence

Monday, September 29, 2014 in Powershell (Views: 1443)
Just a quick one, if you are wanting to check to make sure you are running in a SCCM Task Sequence before continuing in on your script... I use this before setting variables and things...

Try
{
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$logPath = $tsenv.Value("LogPath")
}

Catch
{
Write-Host "This script is not running in a task sequence"
$logPath = $env:windir + "\temp"
}

 

Related Blogs You May Be Interested In:


To leave a comment, please log in and/or register.