Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Adding to wWWHomePage field in AD

$
0
0

I am trying to figure out why when adding a date to the wWWHomePage field in it works on some accounts and not others. Tested on win 7 and 10, some users when running script won't enter in information. The error is :

Set-ADUser :</g> Invalid type 'System.Management.Automation.PSObject'.
Parameter name: wWWHomePage
At C:\Users\Public\Desktop\offboarding.ps1:16 char:11
+ Set-ADUser <<<<  $Username -Replace @{wWWHomePage=$now=Get-Date -format "dd-MMM-yyyy"}
    + CategoryInfo          : InvalidArgument: (Phil.test:ADUser) [Set-ADUser], ArgumentException
    + FullyQualifiedErrorId : Invalid type 'System.Management.Automation.PSObject'.
Parameter name: wWWHomePage,Microsoft.ActiveDirectory.Management.Commands.SetADUser
 

I have also tried the use -Add instead of -Replace (line 16) still the same error for some users<g class="gr_ gr_13 gr-alert gr_gramm gr_inline_cards gr_run_anim Style replaceWithoutSep" data-gr-id="13" id="13">.Below</g> is the script being used.

import-module activedirectory
Start-Sleep -Seconds 10
$username = Read-Host 'Please enter Username!'
Get-ADPrincipalGroupMembership $username | Get-ADGroup -Properties * | select name, description | export-csv Network shared drive\$username.csv
Start-Sleep -Seconds 10
Set-aduser -Identity $Username -Replace @{msExchHideFromAddressLists= $true}
$users = (Get-ADUser $username -properties memberof).memberof
$users | Remove-ADGroupMember -Members $username -Confirm:$false
Start-Sleep -Seconds 5
Disable-ADAccount -Identity $username
Start-Sleep -Seconds 2
Get-ADUser $username | Move-ADObject -TargetPath 'OU for termed users'
Start-Sleep -Seconds 10
Invoke-Command -ComputerName Run AD sync command
Start-Sleep -Seconds 5
Set-ADUser $Username -ADD @{wWWHomePage=$now=Get-Date -format "dd-MMM-yyyy"}

If someone might be able assits in explaining why this is happening or possible solution.




Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>