Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script not detecting that it is running as system #40

Open
Paul-Spagnola-Work opened this issue Aug 3, 2022 · 3 comments
Open

Script not detecting that it is running as system #40

Paul-Spagnola-Work opened this issue Aug 3, 2022 · 3 comments

Comments

@Paul-Spagnola-Work
Copy link

Paul-Spagnola-Work commented Aug 3, 2022

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)
	}
}
@nicolonsky
Copy link
Owner

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.

@Paul-Spagnola-Work
Copy link
Author

Paul-Spagnola-Work commented Aug 4, 2022 via email

@Paul-Spagnola-Work
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants