How i can pass parameter to (Get-PnPUser | ? Email -eq ($SPUserEmail)); #2701
Unanswered
mvcsharepointdev
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following PnP PowerShell script, which read data from SQL Server and update SharePoint using PnP PowerShell:-
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=$DBServer;Integrated Security=True;Initial Catalog=$DBName") $conn.Open(); $query = $Query $dap = new-object System.Data.SqlClient.SqlDataAdapter($query,$conn); $dt = new-object System.Data.DataTable; $null = $dap.Fill($dt) foreach($r in $dt.Rows ) { $SPUserEmail = $r["email_address"]; $SPuser = (Get-PnPUser | ? Email -eq ($SPUserEmail));}
but i will always get this error:
The specified user could not be found.
but if I type the email address manually i will get the user:
$SPuser = (Get-PnPUser | ? Email -eq test@test.com);
although when I do
Write-Host $SPUserEmail
I will gettest@test.com
So what could be the reason?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions