Forum Discussion
Problem with Entering Credentials to the Windows Credential Manager via Intune
Hi All,
I have been trying to get the following script to work to enter "Windows Credentials", not "Generic" credentials into the Windows Credential Manager via Intune Win32 App. It says successfully installed on my Win32 Apps page of Intune, but never adds the credentials. This is the script:
-------------------------------------------------------
# Define the credentials
$target = "10.10.10.10"
$username = "testname"
$password = "testpassword"
# Convert the password to a secure string
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
# Create the credential object
$credential = New-Object System.Management.Automation.PSCredential($username, $securePassword)
# Add the Windows credential to the Credential Manager
cmdkey /add:$target /user:$username /pass:$password
Write-Output "Windows credential added successfully."
-------------------------------------------------------------------------
I use the following "Custom" detection rule script:
# Define the target name for the credential
$target = "10.10.10.10"
# Check if the credential exists
$credential = cmdkey /list | Select-String -Pattern $target
if ($credential) {
Write-Output "Credential exists"
exit 0
} else {
Write-Output "Credential does not exist"
exit 1
}
---------------------------------------------------------------
I use the following "Install Command" to run the install of App:
powershell.exe -ExecutionPolicy Bypass -File .\Windows_Creds.ps1
Cannot figure out why it won't write the credentials. I can get other scripts to make "Generic" easily, but cannot get it to create a set of "Windows Credentials". Any help would be appreciated.
Thank you,
Intuneme
- I am back from vacation, I tested in the "User" context, and all works without issue! Thank you very much. I appreciate it!!
7 Replies
- You do run this as User, not as System?
- IntunemeCopper Contributor
- https://learn.microsoft.com/en-us/windows-server/security/windows-authentication/credentials-processes-in-windows-authentication#windows-vault-and-credential-manager
Credential Manager is for the user itself, not for SYSTEM. If you want to add credentials for a user, you should let the Win32 App run as User.