I’ve spent hours today trying to figure this one out. I am logging in correct to Admin, I can see it in the top right, however, My settings and security Tab is gone and I am no longer able to use admin functions. Has anyone seen this? is my code wrong?
please and thank you!
Set-PSUAuthenticationMethod -ScriptBlock {
param(
[PSCredential]$Credential
)
$domain = $env:USERDOMAIN
$username = $Credential.UserName
$password = $Credential.GetNetworkCredential().password
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext $ct,$domain
if($pc.ValidateCredentials($username,$password))
{
if(get-adgroupmember "ACL-APP-PSUniversal-Admin" -Recursive | where {$_.samaccountname -eq $username})
{
New-PSUAuthenticationResult -Success -UserName "Admin"
}
elseif (get-adgroupmember "wksgrp-lockscreens-users" -Recursive | where {$_.samaccountname -eq $username})
{
New-PSUAuthenticationResult -success -username 'LS_Admin'
}
elseif (get-adgroupmember "wksgrp-Audit-users" -Recursive | where {$_.samaccountname -eq $username})
{
New-PSUAuthenticationResult -success -username 'Audit_Admin'
}
elseif (get-adgroupmember "wksgrp-Query-users" -Recursive | where {$_.samaccountname -eq $username})
{
New-PSUAuthenticationResult -success -username 'Query_admin'
}
else {
New-PSUAuthenticationResult -ErrorMessage 'User not part of allowed group. Contact administrator'
}
}
else
{
New-PSUAuthenticationResult -ErrorMessage 'Bad username or password1'
}
}
New-PSURole -Name “Administrator” -Policy {
param(
$User
)
#
# Policies should return $true or $false to determine whether the user has the particular
# claim that require them for that role.
$user.identity.Name -eq "Admin"
}