acer460527

Forum Replies Created

Viewing 15 posts - 61 through 75 (of 94 total)
  • Author
    Posts
  • in reply to: how to get value of account enabled from aduser #221703
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    no worries thanks for your help

    in reply to: how to get value of account enabled from aduser #221661
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    @Olaf
    in this scenario the code will proceed when the account is enabled right? so If I want to change this then I would need to

    in reply to: how to get value of account enabled from aduser #221628
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    Hi
    thanks for that, it still gives me “exit script” as output

    when I ask the content of $accountEnabled the value is False

    any thoughts on how to capture the $value =”False” correctly in the if statement?

    in reply to: how to catch the exceptions #219864
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    @Rob thanks for your help however when I run your version there is nothing that is removed I get these errors

    when I run my version the groups do get removed correctly can it be that this has something to do with the PScustomobject?

     

     

    in reply to: how to catch the exceptions #219561
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    in addition to the above script, and I can’t figure out how to add this I would like to add the following

    total nr of groups a user is member of
    total nr of groups the user is removed from
    total nr of groups we where not able to remove the user from

    thanks for any pointers in this direction

    in reply to: how to catch the exceptions #219450
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    I use the powershell ISE editor

    … hmm … strange … when I use the the ISE and paste some code the indentation is retained.

    what do you use as editor notepad++ or a different one?

     

    in reply to: how to catch the exceptions #219411
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    I use the powershell ISE editor

    in reply to: how to catch the exceptions #219243
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    here’s the code again and I’ve added the variable again however what I don’t understand at this point is why it’s working even without adding the second $removeAzureAdGroupMember

    foreach ($user in $users) { #get the users objectID from Azure $UserObjectID =get-AzureAdUser -objectId $user.SamAccountName |select objectID #grab the clean objectID from the user $SelectUserObjectID= $userObjectID.objectID #find all the groups a user is member off $UserObjectIDGroupMemberShip = get-AzureAdUserMembership -objectID $SelectUserObjectID foreach ($group in $UserObjectIDGroupMemberShip) { #remove the user from each indivudual group try { $removeAzureAdGroupMember = Remove-AzureADGroupMember -ObjectId $group.objectID -MemberId $SelectUserObjectID $removeAzureAdGroupMember } catch { #the groups that cannot be removed are safed in the error log “Error removing $group” + “:” + “$_” |Add-Content $ErrorLog } finally { #output on screen Write-host “user is removed from ” + “-” + $group.DisplayName } } } [/crayon]

    ps don’t know what is wrong with the indents but can’t get it working correctly mea culpa

    • This reply was modified 5 months, 1 week ago by acer460527.
    in reply to: how to catch the exceptions #219225
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    @olaf,

    I don’t understand why it got removed but here’s the code again

    • This reply was modified 5 months, 1 week ago by acer460527.
    • This reply was modified 5 months, 1 week ago by acer460527.
    • This reply was modified 5 months, 1 week ago by acer460527.
    in reply to: how to catch the exceptions #219039
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    Great. Thanks for sharing.

    Just as an aside note: You declare the variable $removeAzureAdGroupMember but you never use it. 😉 And you should do yourself and all others a favor and indent your code to make it easier readable. You may read the Powershell Best Practice and Style Guide.

    don’t quite understand your remark on the $removeAzureAdGroupMember because when I check the user in question the groups that can be removed are removed. concerning the the readability of the code I copy pasted it from my original powershell window and the indents are there

    • This reply was modified 5 months, 1 week ago by acer460527.
    in reply to: how to catch the exceptions #218880
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    if someone is interested here’s the final working script

    • This reply was modified 5 months, 1 week ago by acer460527.
    in reply to: how to catch the exceptions #218841
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    thanks for the tip

     

    in reply to: howto save my word document as #217344
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    @doug I’m talking about 96 doc that need to checked.

    how do I change the name of the doc from original.docx to fedex_original.docx? also keeping in mind that I have to go through all these 96 docs and rename the ones where Fedex is found?

     

    in reply to: Modify date in description field from user account #217047
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    thanks guys
    I started to experiment with your examples and came up with this

    • This reply was modified 5 months, 2 weeks ago by acer460527.
    • This reply was modified 5 months, 2 weeks ago by acer460527.
    in reply to: Modify date in description field from user account #217014
    Participant
    Topics: 41
    Replies: 94
    Points: 560
    Rank: Major Contributor

    found it

     

    • This reply was modified 5 months, 2 weeks ago by acer460527.
Viewing 15 posts - 61 through 75 (of 94 total)