Note that there are some explanatory texts on larger screens.

plurals
  1. POGet-WmiObject credentials not working when scheduled
    primarykey
    data
    text
    <p>I have a Powershell script to detect disk space on a network server that requires a user/password to access it.</p> <p>I followed this: <a href="http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/440ab7ed-7727-4ff7-a34a-6e69e2dff251/" rel="nofollow">http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/440ab7ed-7727-4ff7-a34a-6e69e2dff251/</a></p> <p>To get this code:</p> <pre><code>$password = get-content C:\creds.txt | convertto-securestring $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "username",$password Get-WmiObject -ErrorAction Stop Win32_LogicalDisk -ComputerName $deviceName -credential $cred -Filter "DeviceID='$darg'" </code></pre> <p><code>$deviceName</code> and <code>$darg</code> are already correctly defined.</p> <p>This works just fine when running the Powershell script manually. But when I set it up as a Windows schedule task, it fails thinking the user/pass is incorrect:</p> <blockquote> <p>Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESS DENIED))</p> <p>$disks = Get-WmiObject &lt;&lt;&lt;&lt; -ErrorAction Stop Win32_LogicalDisk -ComputerName $deviceName -credential $cred -Filter "DeviceID='$darg'" + CategoryInfo : NotSpecified: (:) [Get-WmiObject], Unauthorized AccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand</p> </blockquote> <p>Why is this? (The account is a local user on the remote server. I've tried entering the credentials on the Schedule interface but it doesn't let me save it, saying invalid login; maybe due to being a local account) <code>ServerName\LocalUser</code> does not work in the Windows Schedule UI, still gives the incorrect login error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload