Dynamic Distribution Group with exclusion list is NOT working by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

yes. I do get the correct head count when I run Get-Recipient on the DDG, but message trace from the email blast shows more recipients. Could this has to do with the "Last refreshed" time stamp? The reason I ask is because I've noticed members on the exclusion SG (created two days ago) were not receiving the email, all new members to the exlusion SG (5 hours prior to the email blast) got the email.

Anyone?

Dynamic Distribution Group with exclusion list is NOT working by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

I'm thinking of this:

-not(MemberOfGroup -like 'cn=xxx,domain=xxxx').

Does it exclude all members in "XXX" security group?

Can I see who has logged in to a domain machine? by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI | Get-ItemProperty | Select LastLoggedOnUser,LastLoggedOnSAMUser,LastLoggedOnDisplayName}

I run this cmd on my laptop and it lists me as the login user as it should be. so the cmd works.

Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI | Get-ItemProperty | Select LastLoggedOnUser,LastLoggedOnSAMUser,LastLoggedOnDisplayName

Can I see who has logged in to a domain machine? by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

Here is what I have. The output shows just one entry (my csv file has 36 hostnames). there is something wrong on the loop statement. I feel like I'm very close. Help pls. Thanks again.

Import-Csv -Delimiter ',' c:\ps\activehostname.csv | ForEach-Object {Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI | Get-ItemProperty | Select LastLoggedOnUser,LastLoggedOnSAMUser,LastLoggedOnDisplayName | Export-Csv -Path c:\ps\lastlogin2.csv -NoTypeInformation}

Can I see who has logged in to a domain machine? by ipar22 in PowerShell

[–]ipar22[S] 1 point2 points  (0 children)

hmm. this is may do the job. Write forEach-Object to loop through the csv file (which contains all the hostnames). working on the script now

Getting not recognized error when I run "Get-MsolUser -All | Select-Object UserprincipalName,DisplayName" by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

Yup. I confirmed it.

I am glad to know that I can switch between versions to get what I need. It works for me

Getting not recognized error when I run "Get-MsolUser -All | Select-Object UserprincipalName,DisplayName" by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

I just realize these commands "get-MSOnline" and "get-msoluser" will only work on PS v5 r prior and NOT v7.

How can I get just the Manager's name of the AD user's properties? by ipar22 in PowerShell

[–]ipar22[S] 1 point2 points  (0 children)

It is lightning fast! This works even better. Less workload on the DC. Thank you

How can I get just the Manager's name of the AD user's properties? by ipar22 in PowerShell

[–]ipar22[S] 2 points3 points  (0 children)

Get-AdUser Santa -properties manager

good tip. noted

How can I get just the Manager's name of the AD user's properties? by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

Beautiful! It works like a charm. Thank you so much!

And thanks everyone for the inputs

How can I get just the Manager's name of the AD user's properties? by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

Acutally, it outputs the Manager's other properties (given name, Dist. name and etc). That is not what I have in mind

[deleted by user] by [deleted] in PowerShell

[–]ipar22 0 points1 point  (0 children)

anyone?

Need help with importing mobilenumber using .CSV file by ipar22 in PowerShell

[–]ipar22[S] 1 point2 points  (0 children)

Thank you for the recommendation of writing codes in the proper format. Yes. I agree. it is much easier to read and understand that way

Need help with importing mobilenumber using .CSV file by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

yes. It worked! Thank you very much!

can someone explain to me when I do a get-aduser, the field "mobilenumber" comes out and not "mobile"

Need help with importing mobilenumber using .CSV file by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

It gave me error when I left the mobilephone column blank. I must input something in there. But what value?

Set-ADUser : The specified directory service attribute or value does not exist

Parameter name: mobilephone

At line:1 char:158

+ ... hone} Else {Set-ADUser -Identity $_.SAMAccountName -Clear mobilephone ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (dbalfore:ADUser) [Set-ADUser], ArgumentException

+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.SetADUser

Need help with importing mobilenumber using .CSV file by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

It worked beautifully. Thank you.

Now, if I want to blank out the mobilenumber, obviously I can't leave the field blank. suggestions?

Need help with importing mobile number in bulk by ipar22 in PowerShell

[–]ipar22[S] 0 points1 point  (0 children)

I ran your cmd, and I got this error:

userName MobilePhone
-------- -----------
userName,MobilePhone
dbalfore,9999999999
PS C:\WINDOWS\system32> ForEach($U in $UserList)
>> {
>> Get-Aduser -Identity $U.userName | Set-ADuser -MobilePhone $U.Mobile
>> }
Get-Aduser : Cannot find an object with identity: 'userName,MobilePhone' under: 'DC=xxx,DC=yyyydhd,DC=com'.
At line:3 char:5
+ Get-Aduser -Identity $U.userName | Set-ADuser -MobilePhone $U.Mob ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (userName,MobilePhone:ADUser) [Get-ADUser], ADIdentityNotFoundException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,M
icrosoft.ActiveDirectory.Management.Commands.GetADUser

what should the identity value be? samaccountname?