I'm trying to run a script against my computers with SCCM. It's a very simple powershell script (it has to be, I'm not much of a scripter), and it works perfectly from the command line. However, when I try to deploy it from SCCM it fails every time. I've tried writing directly to the share, I've tried mapping a drive, I've tried deploying it with admin rights and using the logged in user's rights.
I'm hoping someone here can tell me what I'm doing wrong. The script is below. I know it works, but I don't know why I can't deploy it.
# Write the value of the AutoAdminLogon key to $val
# If the AutoAdminLogon key information exists and it is anything other than 0
# write that information to a file on a network share.
# File will be <computername>.txt
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
I'm trying to run a script against my computers with SCCM. It's a very simple powershell script (it has to be, I'm not much of a scripter), and it works perfectly from the command line. However, when I try to deploy it from SCCM it fails every time. I've tried writing directly to the share, I've tried mapping a drive, I've tried deploying it with admin rights and using the logged in user's rights.
I'm hoping someone here can tell me what I'm doing wrong. The script is below. I know it works, but I don't know why I can't deploy it.
# Write the value of the AutoAdminLogon key to $val
$val = Get-ItemProperty -Path "hklm:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name "AutoAdminLogon"
# If the AutoAdminLogon key information exists and it is anything other than 0
# write that information to a file on a network share.
# File will be <computername>.txt
if($val)
{
if($val.AutoAdminLogon -ne 0)
{
$val | Out-File \\<sharelocation>\AutoAdminLogonLog\$env:COMPUTERNAME.txt"
}
}
Share this post
Link to post
Share on other sites