Quantcast
Channel: Configuration Manager 2012 - Operating System Deployment forum
Viewing all articles
Browse latest Browse all 9126

powershell Microsoft.SMS.TSEnvironment

$
0
0

Hey,

during OSD Task Sequence I try to run a PowerShell script which is started through command line in a legacy package.

The command line looks like the following because of architecture information I read I tried two):

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "& {%~dp0SysInst_Silent.ps1}"

%windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "& {%~dp0SysInst_Silent.ps1}"


Powershell script is like the following:

$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$name = $TSEnv.Value("OSDComputerName")

Unfortunately the script (when executed form package in TS step) fails in both cases with error:
"Retrieving the COM class factory for component with CLSID {2D26B0A2-A1C9-4E75-84CB-9102F6842FE5} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

When I create a pause step (just open a notepad) during the Task Sequence and run the Script via "F8" it works without any problems like the following:

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "& {%~dp0SysInst_Silent.ps1}"

Any Idea where the difference is?

Thanks


Viewing all articles
Browse latest Browse all 9126

Trending Articles