Mar 13 2020 07:24 AM
Hi
Just trying to get powershell to update sharepoint which is working if i use an individual account please see the current script
Get-Module SharePointPnPPowerShell* -ListAvailable| Select-Object Name,Version| Sort-Object Version -Descending
Install-Module SharePointPnPPowerShellOnline
Update-Module SharePointPnPPowerShell*
Install-Module AzureAD
Connect-AzureAD
$aaduser = Get-AzureADUser -ObjectId "User1@example.com"
Connect-PnPOnline –Url https://admin.sharepoint.com
if('' -ne $aaduser.facsimileTelephoneNumber -and $null -ne $aaduser.facsimileTelephoneNumber) {
Set-PnPUserProfileProperty -Account $aaduser.UserPrincipalName -Property 'fax' -Value $aaduser.facsimileTelephoneNumber
How ever when i try to get this to run across all users in azure it fails to work the following script is this
Get-Module SharePointPnPPowerShell* -ListAvailable| Select-Object Name,Version| Sort-Object Version -Descending
Install-Module SharePointPnPPowerShellOnline
Update-Module SharePointPnPPowerShell*
Install-Module AzureAD
Connect-AzureAD
$aadusers = Get-AzureADUser -All $true
Connect-PnPOnline –Url https://admin.sharepoint.com
if('' -ne $aaduser.facsimileTelephoneNumber -and $null -ne $aaduser.facsimileTelephoneNumber) {
Set-PnPUserProfileProperty -Account $aaduser.UserPrincipalName -Property 'fax' -Value $aaduser.facsimileTelephoneNumber
Could anyone point me in the correct direction
Thank you
Mar 18 2020 03:06 PM
Solution@bluecoat2020 I think you are missing a foreach so you can loop through each user in $aadusers.
Foreach($aaduser in $aadusers)
{
If('' -ne $aaduser.facsimileTelephoneNumber -and $null -ne $aaduser.facsimileTelephoneNumber)
{
Set-PnPUserProfileProperty -Account $aaduser.UserPrincipalName -Property 'fax' -Value $aaduser.facsimileTelephoneNumber
}
}
Regards
Erick Moreno
Mar 19 2020 07:54 AM
Thank you very much that has worked really appreciated @Erick A. Moreno R.