Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert Get-ADUser to Get-PnPAzureADUser

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading