Give this one a go.
https://4sysops.com/archives/create-a-list-of-local-administrators-with-powershell/
--please don't forget to upvote
and Accept as answer
if the reply is helpful--
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Using the username, I want to find a way to check if that user is an administrator for a given remote server.
I found the following function online but it only checks if the user is an admin for the local machine.
Any help is appreciated!
function Test-Administrator
{
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
Give this one a go.
https://4sysops.com/archives/create-a-list-of-local-administrators-with-powershell/
--please don't forget to upvote
and Accept as answer
if the reply is helpful--
Hi,
You might want to refer to this article:
https://devblogs.microsoft.com/scripting/check-for-admin-credentials-in-a-powershell-script/
Also PowerShell version higher than 5.1 (Windows Server 2016) contains Get-LocalGroupMember cmdlet.
$user = "$env:COMPUTERNAME\$env:USERNAME"
$group = 'Administrators'
$isInGroup = (Get-LocalGroupMember $group).Name -contains $user
Thanks for your time.
Best regards,
Danny
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Just checking if there's any progress or updates?
--please don't forget to upvote
and Accept as answer
if the reply is helpful--