IntuneDriveMapping
IntuneDriveMapping copied to clipboard
Script not detecting that it is running as system
For some reason the Test-RunningAsSystem is returning false even though the start-transcript header shows the user as DOMAIN\SYSTEM
I am making the following suggestion for changing the fuction:
Original function:
#check if running as system
function Test-RunningAsSystem {
[CmdletBinding()]
param()
process {
return [bool]($(whoami -user) -match "S-1-5-18")
}
}
Suggested function (which is working properly in my testing):
#check if running as system
function Test-RunningAsSystem {
[CmdletBinding()]
param()
process {
return [bool]([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem)
}
}
The suggested edit is actually not an option as no check is performed at all, you just return a ‘bool’ which translates to false by default.
Github formatted it wrong. I'll fix it.
I noticed it posted wrong, but when I edited the post and added the correct code markup, I forgot to click save. I just hist save now.