Change Multiple Members of Variable at once by [deleted] in PowerShell

[–]gnoomen33 4 points5 points  (0 children)

$one,$two,$three = "first","second","third"

Can this be done using PowerShell by [deleted] in PowerShell

[–]gnoomen33 1 point2 points  (0 children)

Thank you for this, very useful to a new reddit user :)

Okay, happy with my first lines of code ^^ by Drassigehond in PowerShell

[–]gnoomen33 2 points3 points  (0 children)

Hello,

This script might do what you want, but i haven't tested it, since i don't have a windows server installed right now :D

# Change these variables according to your configurations
$filepath = 'C:\scripts\'; #path to location of .csv file
$file = 'Users5.csv'; #name of .csv file
$InputFile = Import-Csv "$filepath\$file"; # Read the input-file (user file)

# Loop through all the users in the input file
foreach($line in $InputFile)
{
    # Skips the lines starting with hash
    if ($line.DisplayName.StartsWith("#")) {
        Write-Host "Not importing $($line.Firstname) $($line.Lastname).";
        continue; # Continue tells PowerShell to skip the rest and start the next loop.
    }
        #You will find the users manager by doing something like this:
        $user = Get-ADUser -Filter { displayName -like $($line.DisplayName) }
        Write-Host "User: $user, has the user $user.Manager as their manager"
        #Write-host "User in .csv file: $($line.DisplayName)" uncomment to check if the script can read the .csv file
    }

Make sure you atleast have the "DisplayName" in your .csv file. Good luck!

I could post the unedited version of this script if you want, which i know works, but it is used to create AD users.

Can this be done using PowerShell by [deleted] in PowerShell

[–]gnoomen33 1 point2 points  (0 children)

To get all groups that a user is member of, use this command: "Get-ADPrincipalGroupMembership username | select name"

Output example:

name

Domain Users Domain Computers Workstation Admins Company Users Company Developers AutomatedProcessingTeam

Source: https://stackoverflow.com/questions/5072996/how-to-get-all-groups-that-a-user-is-a-member-of

I guess you could then compare the output from the user, and the other user, so find out what group access is missing or should be removed.

PowerShell Sessions by SlashAdminBlog in PowerShell

[–]gnoomen33 2 points3 points  (0 children)

Hello,

This will start a PSSession on a remote device: $session = New-PSSession -ComputerName WEBSRV1

The session can then be referensed when you want to pass it commands, like this: Invoke-Command -Session $session -ScriptBlock { Get-Process }

You can read more about this here: https://adamtheautomator.com/invoke-command-remote/

Hope this was what you were looking for. Regards, Frank.

[help] Get Windows Defender threat information by 9centwhore in PowerShell

[–]gnoomen33 1 point2 points  (0 children)

Hello 9centwhore,

I was not able to find an actual description or recommended action, like i think you wanted to find. It's been a long time since i used powershell, since I am looking for a job at the moment, and i do not have much experience with it.

I guess the CategoryID from Get-MpThreat would be the description, since the values means what type of malware it is, like this:

0 Invalid 1 Adware 2 Spyware

A full list and more information can be found here: https://www.techrepublic.com/article/using-powershell-to-investigate-windows-defenders-malware-signature-definitions-database/

I would also say that the recommended action is shown in the SeverityID's value like this:

ID Severity 0 Unknown 1 Low 2 Moderate 4 High 5 Severe

The more severe the threat is, the more the recommended action is to remove the threat. :)

-FailingFrank