Forum Discussion
SharePoint Online - PowerShell Apply Theme - Problem
Hi Jörg,
this seems to be a quirk in how PowerShell treats the $null input versus the expected [String] parameter. SharePoint can deal with these 2 parameters being null but PowerShell is not happy about it.
I found 2 simple ways of resolving the issue:
1.Pass [NullString]::Value to the function call
$site.ApplyTheme($themeUrl, [NullString]::Value, [NullString]::Value, $false)
2. Pass Out-Null to the function call
$site.ApplyTheme($themeUrl, (Out-Null), (Out-Null), $false)
Both worked fine in my tests.
By the way - I am not a PowerShell expert (I am a SharePoint Developer) but I could find plenty of very complex discussions around passing $null to PowerShell functions - it seems that it is quite complex and not always fully intuitive.
Hope this helps!
Cheers,
Piotrek
Hello Piotrek,
thank you very much. The Microsoft Support gave me the same solution, and now it works fine.
Cheers,
Jörg