deploy application depending on location of computer SCCM 2012

Hello to all,

The problem i am facing is:
Created MSI deployment in the " PSDeployment Toolkit" then there is an extra copy action. place 2 shorcuts into the folder C:\appdata\microsoft\wondows\startmenu.

The first action “install MSI” is no problem, however the second action seems not to work.
I would like to place the 2 shortcuts in the startmenu sould also be no problem however, the tricky part is:
It should be a shortcut depending on the location of the computer.

What I have tried is:
$computer=Get-WmiObject -class Win32_Computersystem
if ($computer.name -like (“PC1”)) {
Copy-file -path “$dirSupportFiles\program1 - lacation1.lnk” -destination “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My Applications\program” -recurse }
elseif ($computer -like (“PC2”)) {
Copy-file -Path “$dirSupportFiles\program2 - location2.lnk” -destination “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My Applications\program” -recurse }

the shortcuts not copy to the machine it should
seems to work only when I use it local.
Also the command: $Computer=[System.Environment]::Machinename is not working.

what do I miss here?
I am using the PSappdeploy toolkit as “application” in SCCM 2012

Jan,

You have an issue related to your $computer variable. Despite the fact that I don’t really understand the concept of “location” with your programs, the Task Sequence do not seems to rely with your computer name.

Do you work in a WinPE OS ? So, use the following command lines to avoid that your script will looking for machinename inside the WinPE OS.
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value(‘OSDComputerName’)

Do you work directly on the operating system during the Task Sequence ?
Prefer to use $env:COMPUTERNAME

Thank you very much Pierick,

I wil try the $env:computername…