Jump to content


pccarrick

Powershell null values

Recommended Posts

Hi I wonder if anyone can help with a very strange problem I am having with a task sequence running on SCCM 2012 R2 SP1.

 

I have a powershell script which runs in a task sequence and gives the user an option to select a time to delay running of the task.

 

The problem I have is that the below section of commands is returning a value of null on some machines in one of our office's. However it is running fine in other offices, if I run the script local on the machine it works fine which is really confusing.

 

 

$datetime = get-date

$current_time = $datetime.ToShortTimeString()

 

$global:AlarmTime = $global:Time.Value

$global:start_time = $global:AlarmTime.ToShortTimeString()

$global:endtime = (new-timespan -Start ($current_time) -end ($global:start_time)).Totalminutes

the problem is with the $global:endtime all other values are returning correct.

 

 

I am running this in the task sequence as a run command line with the following syntax.

 

ServiceUI.exe -process:TSProgressUI.exe C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -WindowStyle Hidden -ExecutionPolicy Bypass -noprofile ".\Updates.ps1"

 

If I run it as a powershell script rather than a command line it won't run at all.

 

 

any help or advise on this would be really appreciated.

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.