Skip to content

Powershell null values

Featured Replies

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.

 

 

 

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.