We have the following Power shell code which connect to onpremsies AD:-
$HiringManger = Get-ADUser -Filter {enabled -eq $True -and mail -eq test@***.com } -SearchBase "OU=Sites,dc=company-tech,dc=net"
and we want to convert Get-ADUser
to Get-PnPAzureADUser
. But when i tried the following i got this error:-
PS C:\WINDOWS\system32> $HRUser = Get-PnPAzureADUser -Filter {AccountEnabled -eq $True -and Mail -eq test@***.com } -SearchBase "OU=Sites,dc=comapny-tech,dc=net"
Get-PnPAzureADUser : A parameter cannot be found that matches parameter name 'SearchBase'.
At line:1 char:114
... -and Mail -eq test@***.com } -SearchBase "OU=Sit ...
~~~~~~~~~~~
CategoryInfo : InvalidArgument: (:) [Get-PnPAzureADUser], ParameterBindingException
FullyQualifiedErrorId : NamedParameterNotFound,PnP.PowerShell.Commands.Principals.GetAzureADUser
Any advice ?
Thanks
CodePudding user response:
Short answer: Get-PnPAzureADUser
doesn't have a -SearchBase
parameter (see Documentation)
Longer answer: In Azure, there is no concept of OU's. Everything is flat. Therefore there is no need for -SearchBase
because there are no OU's to filter/sort/group by.