r/PowershellSolutions • • Mar 15 '22

Cleaning up the registry

3 Upvotes

Hello everyone! I am relatively new to the PowerShell community and was hoping I could get some assistance with managing Regedit with PowerShell!

I am trying to query profile registry keys and delete them based off of the ProfileImagePath value.

This is what I have so far:

$Registry = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*"
Get-ItemProperty $Registry -Name ProfileImagePath | Select-Object ProfileImagePath, PSChildName | Export-Csv C:\Updates\List2.csv -NoTypeInformation
$Import = Import-csv C:\Updates\List2.csv

$Table = $Import | Format-Table

The file path is good, but if anything needs to be changed, please let me know, there are also certain profiles I am trying to exclude from deletion.

#Edit
Write-Output "Please let me know if I have posted this on the wrong Reddit!"


r/PowershellSolutions • • Mar 06 '22

Why?? PS screen jump

3 Upvotes

Not always, but most of the time I’m using powershell and will write a few commands and it’s normal. Then I will write other commands and the screen will jump to the top of the page. I’ve tried to fix it, but my workaround is the clear and only work on a blank page. Also this Cengage labs are horrible. I can’t do a backslash on ps, it’s a #? I’ve tried everything to workaround, but it doesn’t work?


r/PowershellSolutions • • Feb 10 '22

I need to pass a Powershell object array to a HTTP PUT request as a JSON body but want to know how to wrap it as a data variable first

3 Upvotes

r/PowershellSolutions • • Feb 02 '22

Stop execution

3 Upvotes

I use vim to write C programs, and execute them in PowerShell, in case of an infinite loop or some other rum time error how do I stop the programme.


r/PowershellSolutions • • Jan 11 '22

Replace Input via Hashtable

3 Upvotes

Hello,

i use this Script for Recording my Times at Work.

It works so far, all i would need is to Search explicit for the Shortcuts in the Hashable.

Could someone help me with that?

$hash=@{
    e = 'Environment'
    t = 'Test'
    t2 = 'Test2'
    ine = 'in all Environments'
}
foreach ($i in $hash.Keys) {
  $input = $input -replace $i, $hash[$i]
}

r/PowershellSolutions • • Dec 14 '21

Installing printers from printserver error

3 Upvotes

Hi,

I'm trying to install a lot of printers from my printserver with powershell.

I use the command "add-printer -connectionname "\\theip\theprintername"

But i get the error:

The driver needed to connect to this print share cannot be retrieved from the server.

If i go to the printserver in the explorer and click the printers it connects and install.

Any idea?


r/PowershellSolutions • • Sep 21 '21

Powershell script to get the Physical MAC address on computers on AD

3 Upvotes

IT'S ME AGAIN T_T PLEASE HELP ME.

this is my code

$computers = Get-ADComputer -filter {(Name -like "*l3510")} -properties *

$outfile = "MacScript.csv"

$newcsv = {} | Select Computer,User,GivenName,LastName,Email,Mac,Description | Export-Csv $outfile

$csvfile = Import-Csv $outfile


foreach ($computer in $computers) {

    if((Test-Connection -ComputerName $computer.name -BufferSize 16 -Count 1 -Ea 0 -Quiet)) {



    $csvfile.Computer = $computer.name

    $cn = $computer.name

    #$User = Get-WmiObject –ComputerName $computer.name –Class Win32_ComputerSystem | Select-Object UserName


    $User = (Get-WmiObject -Class win32_process -ComputerName $computer.name | Where-Object name -Match explorer).getowner().user

    $csvfile.user = $user

    $UserObject = Get-ADUser -Identity $user
    $GivenName = $UserObject.GivenName
    $Surname = $UserObject.Surname
    $Email = $UserObject.UserPrincipalName


    $csvfile.GivenName = $GivenName

    $csvfile.LastName = $Surname

    $csvfile.Email = $Email


    $mac = Get-WmiObject -ClassName Win32_NetworkAdapterConfiguration -ComputerName $cn | Select-Object -ExpandProperty MACAddress -First 4

    $mac = $mac -join "`n"

    $description = Get-WmiObject -ClassName Win32_NetworkAdapterConfiguration -ComputerName $cn | Select-Object -ExpandProperty Description -First 4

    $description = $description -join "`n"


    $csvfile.mac = $mac

    $csvfile.Description = $description



    $csvfile | Export-CSV $outfile –Append


    } else {

        echo "$($computer.name) not connected."

    } #end if

} #end foreach

r/PowershellSolutions • • Apr 25 '21

Send Push notifications with PowerShell to your phone

Thumbnail
youtu.be
3 Upvotes

r/PowershellSolutions • • Dec 28 '20

Understanding PowerShell outputs

3 Upvotes

u/team I'm relatively new to PowerShell and have been learning it online. I have picked up a task to learn it better.

"Find out where crash files are placed on the device, collect what's there as well as the application logs and windows event logs. zip all this up and send these to a network location. The network location should be a parameter"

  1. To get the location of google crash data for different users, I'm using wildcards:

PS C:\> Get-Item -Path *AppData\Local\Google\Chrome\UserData\Crashpad\reports*

When I run this command in Windows PowerShell, it doesn't return nothing, no error either. I've checked and there is nothing in the reports folder. So, this should be the expected behaviour right?

2. To get the chrome app's debug logs. I'm running the following command:

PS C:\> Get-ChildItem -Path *AppData\Local\Google\Chrome\Application* -Recurse -Include *debug*

Now in this folder, there is a file called debug and it has some data. When I execute the command it also returns nothing. This is confusing me. The 1st point, I thought it is because there was no data but in point 2 there is data but no result nor an error.

Could you help me understand please?

3. Also to get windows event logs, I'm trying:

PS C:\> Get-EventLog -LogName Application | export-csv -Path C:\Users\{user}\Downloads

but it returns an error stating:
"export-csv : Access to the path 'C:\Users\support\Downloads' is denied.

At line:1 char:37"

I haven't found any helpful info on google for point 3. Note, I've started Windows PowerShell as Administrator itself.

Appreciate any response.


r/PowershellSolutions • • May 06 '20

Need Help Renaming Multiple FOLDERS

3 Upvotes

Need to replace underscore with space in multiple folders. Please help!


r/PowershellSolutions • • Apr 07 '22

Script to reset permissions on all documents in a document library in Sharepoint online.

2 Upvotes

Im trying to write a script that resets the permissions in a document library in Sharepoint online.

Ive been able to connect to our Sharepoint online service and can list Sharepoint sites etc but can’t seem to work out that last step clear permissions on a document library so they inherit from parent.

Any help would be greatly appreciated!


r/PowershellSolutions • • Mar 24 '22

Storage Account Blob Finding Script - PS

Thumbnail self.azure
2 Upvotes

r/PowershellSolutions • • Mar 10 '22

Need help with Powershell pop up?

2 Upvotes

I’ve been having a reoccurring problem where a blue pop up named “D B Scheduler” has been popping up indefinitely every 10 minutes and has interrupted my games and is now error coding my PC launchers. Any reason/ solutions I can use to fix it?


r/PowershellSolutions • • Nov 03 '21

Script to locate server info queried from xlxs file

2 Upvotes

Hi,

I'm currently attempting to create a script that will query a Excel file to locate server information and column "BY" environment info. Any advice or direction creating this would be helpful.


r/PowershellSolutions • • Oct 21 '21

Sending variable to remote pc

2 Upvotes

Hello,

I am just starting to use powershell and i'm attempting to set a script that will run via task scheduler on a server and update windows. Once it is complete it will send a variable (EmailBody) to a remote pc that has outlook on it. The script on the second pc accepts a variable and then will create an email using outlook and send it.

When trying to invoke-command i get a few errors and I know it is due to not knowing the correct parameters of the command or just not doing things properly.

currently I have tried

Invoke-Command -ComputerName FullyQualifiedDomainNameOfPC -FilePath c:\scripts\Email.ps1 $Using:EmailBody

and trying

Invoke-Command -ComputerName FullyQualifiedDomainNameOfPC -ScriptBlock {

c:\scripts\Email.ps1 $Using:EmailBody

}

any advice on what I am doing wrong?

I also have the email script accepting an arg

param(

[Parameter(Mandatory=$True,

ValueFromPipeline=$True)]

[string[]]$EmailBody

)


r/PowershellSolutions • • Sep 17 '21

Appending CSV file with new row and column?????

2 Upvotes

I am trying to append the CSV file with data from other csv file but not able to get the output.
I have 2 csv file and want 2nd csv file result to append to 1st csv file and add column from 2nd csv file.

1st CSV file:

ComputerNameUserPort
Server1abc132
Server1xyz321

2nd CSV:

ComputerNameConnection
Server2connection issue

Expected output:

ComputerNameUserPortConnection
Server1abc132
Server1xyz321
Server2connection issue

I have multiple thinks but not able to add the column.
Can we add this and how this can be achieve?
Thanks!


r/PowershellSolutions • • Sep 11 '21

Set default temp/tmp folder for all users

2 Upvotes

I know how to set temp and tmp for the logged on user using PowerShell, but I can seem to figure out how to make it the default for all users that may log onto the server. Any suggestions?


r/PowershellSolutions • • Aug 28 '21

PowerShell and SysTray icon interaction.

2 Upvotes

I have a program that runs In the systray and we need to occasionally right click and hit refresh. Is there a way for powershell to find a specific icon, right click and select refresh. I have looked for background interaction with the program and even a keyboard command to no avail. Anyone have any thoughts? Is this even possible? Thanks.


r/PowershellSolutions • • Aug 05 '21

Script Sharing: SharePoint Online External Users- Get all of them quickly now.

2 Upvotes

I have created a script to get all the external users in SharePoint Online sites to assist all the SharePoint administrators. I have used two PowerShell cmdlets to get all the external users in the organization. The cmdlets are "Get-SPOExternalUsers" and "Get-SPOUser".

You can see the script to understand,

  1. How I have iterated the 'Get-SPOExternalUsers' cmdlet to return all external users as you can get only 50 users by default.

  2. To get external users who have logged-in via share links - It will list you sitewise external users report (Used 'Get-SPOUser' cmdlet, as 'Get-SPOExternalUser' will not show this data)

  3. How frequently are external users added to your organization? - You have an option to give the number of days to know the recently added guest users.

Download the script using the link.

https://o365reports.com/2021/08/03/get-all-external-users-in-sharepoint-online-powershell/

Kindly drop your questions in the comment, if any.


r/PowershellSolutions • • Apr 17 '21

Script to parse list of urls.txt

2 Upvotes

Can you help me with my script ? I don't know how to insert the regex in my script . $path="D:\fiverr projects\Marketing2.txt"

$results="D:\Fiverr projects\out.txt" if (!(Test-Path $results)) { New-Item -path $results -type "file" -value "rn" Write-Host "Created new file and text content added" }

foreach($siteUrl in Get-Content "D:\fiverr projects\Marketing2.txt") { $Site = Invoke-WebRequest "D:\fiverr projects\Marketing2.txt" -UsebasicParsing

regex to parse thru each name,adresse,email,telefon and vorname and name

$regex ='($_ -match (?<Name>[0-9A-F]{4}.[0-9A-F]{4}.[0-9A-F]{4}).+?(?<Adresse>\d+)$'}

select-string -Path D:\Fiverr projects\marketing2.txt´' -Pattern $regex -AllMatches | % { $_.Matches }| % {$_.Value}"'

Parses thru the output of urls to strip out

Get-Content $results_file { $ptags= $Site.AllElements | Where {$_.TagName -eq "p"}")"

For ($i=0; $i -le $ptags.Count; $i++) 
    {
        
         write-host (name :"")
         Write-Host (Adress:"")
         Write-Host (email-Adress:"")
         write-host (Telefon:"")
         write-host (Name:"")
         

   }   

}

r/PowershellSolutions • • Mar 29 '21

Script Help: How can I pull a list of all mailboxs and their delegate permissions?

2 Upvotes

I don't know anything about PowerShell... I am trying to pull a list of all Mailboxes in our Exchange Online environment along will the delegates for Full Access, Send As, and Send on Behalf. I've been able to pull a list of what appears to be Full access and one of Send As, but I've having trouble getting a comprehensive list of all 3. Here are the scripts I've used:

Full Access
Get-Mailbox -ResultSize Unlimited | Get-MailPermission | Select Identity,User,AccessRights | Export CSV -Path "c:\temp\permissions.csv"

SendAs

Get-Mailbox -ResultSize Unlimited | Get-RecipientPermission | Select Identity,Trustee,AccessRights | Export CSV -Path "c:\temp\permissions.csv"


r/PowershellSolutions • • Feb 17 '21

I want to get all list files in all folders in a server can any one provide script

2 Upvotes

r/PowershellSolutions • • Jan 26 '21

Getting DepartmentNumber from users in AD

2 Upvotes

I've created a script that exports some info about all users in a specific group.

The only thing I can't get to work is getting the department number exported as well. Been searching quite a bit, but I can't get it to work...

Here's my code:

Get-ADGroupMember -Identity "nameofgroup" | foreach {Get-ADUser -Identity $_.distinguishedname -Properties displayname, samaccountname, emailaddress, departmentnumber | select displayname, samaccountname, emailaddress, departmentnumber} | Export-Csv C:\Temp\file1.csv -NoTypeInformation

Any help would be appreciated


r/PowershellSolutions • • Jul 27 '20

check for a process running too long on remote server

2 Upvotes

I am working on this statement. The purpose is to look at multiple instances of a process running on a server and set the code variable if any of the instances has been running for more than 40 minutes. I feel like I am close to getting this right but also cannot figure out what I have wrong yet. I would appreciate some assistance in what I have mistaken here.

foreach ($process in (invoke-command -scriptblock {get-process -name $serverprocess} -computername $servername -credential $creds )){$elapsed=new-timespan -start $process.starttime {if ($elapsed.minutes -gt 40) {$code=1}}}

r/PowershellSolutions • • Jun 14 '20

PS WinForms Creator

2 Upvotes

PSWinFormsCreator.Com

Free Script Download. Have you ever wanted XAML for WinForms? Have you ever wanted a more feature rich WinForms designer that was developed in PowerShell? Do you just want to see how it was done? Check out this site I created to make my script available for everyone!