Sum Wum
asked on
SCCM - Run powershell script as a program
Hi,
I really need some help here.
I want to uninstall Lync 2010 and it's MUI pack with SCCM. For that i've made this powershell script:
I want to run this powershell script as a program from SCCM 2007 R3. I've tried these command so far:
Powershell.exe -ExecutionPolicy Bypass -file "\\Server\Lync\blabla\Unin stall.ps1"
Powershell.exe -ExecutionPolicy Unrestricted -file "\\Server\Lync\blabla\Unin stall.ps1"
All that happens when they run, is that powerhell starts up and then nothing.
I've also tried with a batch script, that copies the powershell-file to the local computer and run it from there, but still nothing happens.
If I run it directly from the file, it Works perfect and removes Lync.
What am I doing wrong? :)
I really need some help here.
I want to uninstall Lync 2010 and it's MUI pack with SCCM. For that i've made this powershell script:
[String]$File = "C:\Program Files\Microsoft Lync\UcMapi64.exe"
[String]$FileExists = (Test-Path $File -PathType Leaf)
[String]$ShortcutPath_01 = "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Lync"
[String]$ShortcutPath_02 = "$env:ProgramData\Microsoft\Windows\Start Menu\Programs\Vestfrost\Microsoft Lync"
[String]$FilePath = "C:\Program Files (x86)\Microsoft Lync"
if ($FileExists -eq $false)
{
Exit
}
elseif ($FileExists -eq $true)
{
#Stopping Lync 2010 from running
Stop-Process -Name "Communicator"
#Uninstalling Lync 2010
Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*Lync*2010*"} | ForEach-Object -process {$_.Uninstall()}
#Deleting shortcuts
Remove-Item -Path $ShortcutPath_01 -Recurse -Force
Remove-Item -Path $ShortcutPath_02 -Recurse -Force
Remove-Item -Path $FilePath -Recurse -Force
}
I want to run this powershell script as a program from SCCM 2007 R3. I've tried these command so far:
Powershell.exe -ExecutionPolicy Bypass -file "\\Server\Lync\blabla\Unin
Powershell.exe -ExecutionPolicy Unrestricted -file "\\Server\Lync\blabla\Unin
All that happens when they run, is that powerhell starts up and then nothing.
I've also tried with a batch script, that copies the powershell-file to the local computer and run it from there, but still nothing happens.
If I run it directly from the file, it Works perfect and removes Lync.
What am I doing wrong? :)
ASKER
Nothing happens when I do that.
Now i've created a .bat file that copy the PS1 file to a local drive and run it from there. Nothing happens. But if i run this file that it has just copied to the local pc, from a cmd, it runs just fine.
Does it make any difference that the SCCM client is a 32-bit and the OS is 64-bit, when I execute the powershell-command from SCCM?
Now i've created a .bat file that copy the PS1 file to a local drive and run it from there. Nothing happens. But if i run this file that it has just copied to the local pc, from a cmd, it runs just fine.
Does it make any difference that the SCCM client is a 32-bit and the OS is 64-bit, when I execute the powershell-command from SCCM?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did get other solutions.
Read-Host "Enter key to Continue"