Dogoodwork

u/Dogoodwork


r/PowerShell•

I do the powershell work for my department, and my manager just asked if there are any tools/etc I need for scripting. Currently I am the only admin here who uses much powershell.

I am quite happy using the powershell ise but if there are some tools, etc that are work their cost I think this is my chance to ask for them.

Please throw anything you think is worth the money at the board - I currently have nothing that wasn't free.

45104

r/PowerShell•

I have a report I am preparing, that is basically done, except that there is this weird, nagging bug that I can bring myself to give up on.

My script users a variable $user, to hold some data on a person from a file for a seperate system. I am trying to match this person up with possible AD accounts that may be the same person. $userFound is an array of (lets say 3) AD User objects where the lastname, and first letter for the first name match with $user.

However, when $userfound is run through a loop to create 3 new objects with the data from $user + email address from $userfound[1..3] the new array always has 3 identical entries where the email address etc is only taken from $userfound[3

167

r/PowerShell•

I have created a JEA endpoint and PWSA front end.

I am having double-hop issues.

When connecting to my pwsa console, I run a command to perform an operation on a client computer (get-wmiobject) , and i get an access denied message.

I will re-post Monday, hopefully with some useful information, but I wanted to throw something out there in case someone has figured this out already.

21

r/PowerShell•

I have a script I have written up do automate some tasks for migrating users from a PST to the Personal Archive (Exchange 2010.)

Sometimes the script fails on the new-mailboximportrequest, with the error "Mailbox could not be opened." Running the same command manually works, or re-running the script works as well.

I added the loop below to try and correct this, but catch doesn't seem to catch... is this because of the remote session?

$Session = New-PSSession -ConfigurationName Microsoft.Exchange 
Import-PSSession $Session 

other things are happening
enable-archive, set quota, etc.

        $failcount = 0
        while($failcount -lt 5) {
        
       
36

r/PowerShell•

We have a bi-directional trust with a partner, and I am working on cleaning up some of our security groups. I am able to identify ForeignSecurityPrincipals

$users = $group | select -ExpandProperty members  | Get-ADObject -server domaincontroller:3268 
Foreach ($u in $users) { 
    if ($u.ObjectClass -like '*Foreign*') {

and convert those objects from SIDs to readable names using Convert-FspToUsername

But I also need to check if that user has an account on my local AD Domain (/forest).

I can't figure out how to query the Trust domain for more detailed user info, such as their proper name

63

r/PowerShell•
$group = [adsi]”LDAP://CN=GiantDistList,DC=workplace,DC=com” 
$members = $group.psbase.invoke("Members") | foreach {$_.GetType().InvokeMember("DistinguishedName",'GetProperty',$null,$_,$null)} 

foreach ($user in $members) {
    Out-File -filepath c:\ps\Everyone.txt -append -InputObject $user 
    try {
        $target = (Get-ADUser -identity $user -ErrorAction Stop)    
    }
    catch {
        Out-File -filepath C:\ps\everyError.txt -Append -InputObject $user
    }
    finally {
        if ($target.Enabled -eq $false) {
            Remove-ADGroupMember -identity GiantDistList -Members $target.SAMAccountName -Confirm:$false
      
117

You've reached the end of this feed.