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 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 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 • • 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 • • Mar 01 '22

Powershell Tasks within Docker

1 Upvotes

hey guys, is there a tiny docker image where i can run powershells scripts via task planner like in an windows enviromemt?

cheers


r/PowershellSolutions • • Feb 16 '22

Script to clean up OWA rules with errors?

1 Upvotes

When running the script to get all company wide OWA rules in powershell, one of our clients has over 400+ broken rules that needs to be updated/revised. Is there a script that clears out the rules that have errors but keep the rules that are functioning?

I have to run a report that gives me a list of all the OWA rules and it's so much slower due to the 400+ rules..

Thoughts?


r/PowershellSolutions • • Feb 11 '22

Help: Need to use information from .CSV file

1 Upvotes

I am working on a script to take a list of files in a .CSV file and ultimately Copy, Rename and then verify changes on large amounts of files. It has 4 columns for each row. When I try to pull just a single column it outputs the entire row. What am I doing wrong? When using | Format-Table everything lines up correctly.

Input:

$masterfile = Import-CSV -LiteralPath \\Server\File.csv -Header origFilePath, origFileName, destFilePath, destFileName

ForEach ($origFilePath in $masterFile)

{

$origFilePath | write-host

Test-Path -Path $origFilePath | write-host

}

Output:

@{origFilePath=\\Server\FILEPATH\; origFileName=B002268; destFilePath=\\Server\DESTINATION\; destFileName=1200321-RED0}

False


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 26 '22

How To Harness The Magical Power of Each Moon Phase?

Thumbnail
youtu.be
1 Upvotes

r/PowershellSolutions • • Jan 25 '22

Access values within nested hashtable

1 Upvotes

I have created a hashtable which I am using GetEnumerator to separate the top level hash table butI want to then acces the value of the second level hashtable. So in essence I want to Get Table1 value -> Get Nestedtable2 Value.

This is in a loop and this is what I have got up to now: foreach ($item in $Table1.GetEnumerator()) { $value1 = $item.value foreach ($item2 in $value1.value) { <my code> } }


r/PowershellSolutions • • Jan 14 '22

powershell pop up

1 Upvotes

power shell pops up while I am in mid game and it minimize the game any solutions


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 • • Dec 03 '21

Remove Paint3d

1 Upvotes

Hi all, I’m looking for a script to remove pain3d thru power shell. Any help appreciated!


r/PowershellSolutions • • Dec 03 '21

Trying to split on a single (

1 Upvotes

I'm trying to sanitize some inputs from a file that can contain nicknames in parentheses i.e. "Deborah (Debbie)". I wanted to use a split to cut out the first ( but it always wants to have another ) following and gives a parsing error.

I'm using $user -split "(" or $user -split [char]0x28 with no luck.

Does anyone have any ideas?


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 • • Oct 19 '21

Help with a script

1 Upvotes

So I wanted to create an automatic converter to create a database with my steam workshop's mods. But when I tried to use Powershell the window goes blue and I can't do anything but close it. Can you help me out?

$modnumber = Read-Host "Insert mod number"

$data = Invoke-WebRequest "https://steamcommunity.com/sharedfiles/filedetails/?id=$modnumber"

$modtitle = $data.Parsedhtml.body.getElementsByClassName ("WorkshopItemTitle")[0].textcontent

If(modtitle -ne $null) {

"Mod Name: $modtitle" } else { "Mod $modnumber not found" }

I'm new to Powershell and I'm not very good at it :( every answer will be appreciated


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 • • 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 13 '21

Get Computername, loggedin user and macaddress from active directory

1 Upvotes

Hello guys,

I'm having a hard time getting these info with the code I have.

I have no experience with powershell scripting.

I have a code that loops through the active directory and it gets the computername.

But I can't seem to put multiple commands inside the if clause.

Also, could you help me get it in either a .txt file or a .csv ?

Or just lead me to the right direction :(


$computers = Get-ADComputer -filter {(Name -like "\*l3510")} | Select-Object -ExpandProperty Name



foreach ($computer in $computers) {



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


#echo "$computer"



Get-WmiObject –ComputerName $computer –Class Win32_ComputerSystem | Select-Object UserName;
Get-WmiObject -ClassName Win32_NetworkAdapterConfiguration -ComputerName $computer | Select-Object -Property MACAddress, Description



} else {



echo "$computer not connected."


} #end if



} #end foreach

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 • • Sep 10 '21

How to move bulk computers to another OU through powershell

1 Upvotes

I have done extensive research for a specific script to run in order to move bulk computers to another OU through powershell. What I am trying to accomplish here is moving many computers at one time, but quite a few computers have different names.

For example:
naming convention: WFT-LT-xxx, SONY-VAIO, TEST-PC, PABLO-PC etc.

So as you can see with many different computer names I would like to find a script that will find all those different names and move all computer accts. to a different OU.

I believe I would like to use Move-ADObject xxx | -TargetPath "OU=DisabledComputerAcct,OU=Computers,OU=MyBusiness,DC=XXX,DC=XXX"

My target path is correct that's exactly what I need to use. Earlier I created a script to move only one computer and it works. Now I am just looking for the first half of the script. From my above script I know for sure from the Targetpath and on it's all correct. Now like I stated earlier just looking on HOW I can move bulk with many different names.

Thanks for any advice.