powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Sync-PnPSharePointUserProfilesFromAzureActiveDirectory - Azure Automation - Error - NoError

Open ClassyGull opened this issue 3 years ago • 3 comments

Reporting an Issue or Missing Feature

When running PowerShell script in Azure Automation to support SharePoint Online Bulk User Profile update leveraging this cmdlet:

Sync-PnPSharePointUserProfilesFromAzureActiveDirectory

The error stream receives Error: NoError

This is valid/documented for job that completes without error. However it is written to the error stream in Azure Automation.

Expected behavior

This should not be written to error stream since its not an error.

Actual behavior

Error : NoError

image

Steps to reproduce behavior

$argsPnpUser = @{ Select = "mobilePhone", "streetAddress", "faxNumber", "state", "postalCode" Filter = "onPremisesSyncEnabled eq true and AccountEnabled eq true" StartIndex = "0" EndIndex = "10000" }

$users = Get-PnPAzureADUser @argsPnpUser

$argsUserProfileSync = @{ UserProfilePropertyMapping = @{ "Cell" = "mobilePhone" "streetAddress" = "streetAddress" "Fax" = "faxNumber" "state" = "state" "zip" = "postalCode" } Users = $users Folder = "Shared Documents/SPO" Wait = $true Verbose = $true ErrorAction = "Stop" }

try { Sync-PnPSharePointUserProfilesFromAzureActiveDirectory @argsUserProfileSync } catch { Write-Error $($.Exception.GetType().FullName) Write-Error $($.Exception.Message) Break }

What is the version of the Cmdlet module you are running?

Pnp.PowerShell 1.11.0 Running on PowerShell 7

Which operating system/environment are you running PnP PowerShell on?

  • [ ] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [X ] Other : Azure Automation (PS7)

ClassyGull avatar Jul 18 '22 18:07 ClassyGull

@ClassyGull are you using PowerShell 7.0 or 7.1?

CallumCrowley avatar Aug 10 '22 08:08 CallumCrowley

PS 7.1

ClassyGull avatar Aug 10 '22 15:08 ClassyGull

Might be worth trying PS 7.0, I recently tried PnP.PowerShell with PS Core 7.2 and I couldn't get it to work, others have reported similar.

CallumCrowley avatar Aug 10 '22 15:08 CallumCrowley

Unfortunately, this is an issue with Azure automation itself and not with PnP PowerShell.

Please store the output of the cmdlet in a variable like this:

try {
$job = Sync-PnPSharePointUserProfilesFromAzureActiveDirectory @argsUserProfileSync
}
catch {
Write-Error .Exception.GetType().FullName)
Write-Error .Exception.Message)
Break
}

After that, the output will not be written in the error stream.

gautamdsheth avatar Oct 10 '22 20:10 gautamdsheth