Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

PENDING SCCM Scripts 2010

  • Thread starter Thread starter miked2189
  • Start date Start date
  • Replies Replies 1
  • Views Views 1K

miked2189

New Member
Messages
1
Reaction score
0
Points
1
Attempting to run the following script using the scripts feature of SCCM, the script does an AD query and determines if computer is a laptop, then removes a file and copies a file. Script seems to run fine with no error messages but nothing ever happens?

If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}

$user = $env:username
$upath = $env:userprofile
$comp = $env:computername
$membersce = Get-adgroupmember -identity "SSLVPN-CountyEmployee" -recursive | select -ExpandProperty SamAccountName
$membershv = Get-adgroupmember -identity "SSLVPN-CountyHVAC" -recursive | select -ExpandProperty SamAccountName

#check if user is part of VPN group
if (($membersce -contains $User) -or ($membershv -contains $User))
{
if (test-connection -Computername $comp -quiet -count 1)
{
if ((Get-WmiObject -Class Win32_ComputerSystem -Property PCSystemType -ComputerName $comp).PCSystemType -eq 2)
{
$script = get-aduser -Identity $user -Properties * | select-Object ScriptPath
$pdpath = "c:\users\public\desktop\" + $script.ScriptPath
$uppath = $upath + "\desktop\" + $script.ScriptPath
$mpath = "\\ncgc-ad.gov\netlogon\" + $script.ScriptPath
if (Test-Path -path $pdpath -pathtype Leaf)
{
Remove-item -Path $pdpath
}
copy-item -path $mpath -destination $uppath -force
}
}
}
 
The Script is likely running a local system account and therefore, likely doesn't have you you need it to have.

The simple way to test this is to add logging to your script then read the log file.
 
Back
Top