If it is a powershell script, you could actually input the username and password with parameter in your SCCM script, and the make the script declare a credential object with those parameters and do a PSSession to the machine itself with these credentials and voila, you are able to execute your powershell script inside that "wrapper"Hello everyone,
I'm looking for a way to run scripts not via the system user but rather for the logged in user. The background is that I want to read out the user's certificates which are about to expire. Is there a possibility here?
Param(
[Parameter(Mandatory=$True, Position = 0)]
[String]$Username,
[Parameter(Mandatory=$True, Position = 1)]
[String]$Password
)
$CredentialPassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($Username, $CredentialPassword)
$ComputerName = ([System.Net.Dns]::GetHostByName($env:computerName)).HostName
$CommandResult = Invoke-Command -ComputerName $ComputerName -ScriptBlock {
$ObjectProperties = @{
ComputerName = ([System.Net.Dns]::GetHostByName($env:computerName)).HostName
Username = $env:USERNAME
UserDomain = $env:USERDOMAIN
}
$Result = New-Object -TypeName psobject -Property $ObjectProperties
return $Result
} -Credential $Credential
return $CommandResult
This is a loaded question? Can you run a script in user mode? For sure, use Packages running in user context.Hello everyone,
I'm looking for a way to run scripts not via the system user but rather for the logged in user. The background is that I want to read out the user's certificates which are about to expire. Is there a possibility here?