Trying to audit total user OneDrive storage for a domain
Reddit » PowerShell
by /u/bitemespez
6h ago
Script should be iterating through all users with a given domain suffix and summing their total OneDrive storage. I'm connecting with user.read.all and files.read.all and the account has global reader and sharepoint admin roles. Here's the code: $users = Get-MgUser -All | Where-Object { $_.UserPrincipalName -like "*$suffix" } $totalSpaceUsed = 0 $userCount = 0 foreach ($user in $users) { $userCount++ try { $drive = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/users/$($user.Id)/drive" Write-Host "$userCount $drive" -ForegroundColor Green $totalSpaceUsed += $drive.q ..read more
Visit website
Get group membership for all users in one OU
Reddit » PowerShell
by /u/EvYnot
6h ago
Looking to get a script to check 1 OU and export to a .csv that shows each user in that group and what groups they are members of. I would like to user the Get -GroupMembership. Disabled Staff accounts is the OU that all the users are in. sAMAccountName or name attribute would need to be displayed in output. Active directory= CompanyName ---Disabled or Restricted Accounts ----------Disabled Staff Accounts submitted by /u/EvYnot [visit reddit] [comments ..read more
Visit website
Netsh interface IPv4 set address "parameter is incorrect"
Reddit » PowerShell
by /u/Koi-Fishy-Pants
11h ago
I'm trying to change my IP via the netsh command and am getting issues with it. When I use the netsh command with my current IP address (top entry in the code below), it works perfectly and changes my IP address, subnet mask, and default gateway in the IPv4 Properties window in the control panel to the correct values. But when I use the netsh command with the IP address I want to switch to (bottom entry in the code below), it changes the IPv4 Properties window in the control panel to "Use the following IP address:" with nothing for each value. In powershell, it gives me the error message: "Th ..read more
Visit website
Is it possible for a powershell script to have awareness of a game currently running?
Reddit » PowerShell
by /u/RoderickHossack
11h ago
I have a powershell script meant to detect if a game is running and either switch to the high performance power plan, or switch to power saver otherwise. Currently, the detection is based on either CPU or GPU utilization going above a certain threshold. The problem is, oftentimes, the game I'm playing doesn't tax my system enough to meet the thresholds, so I get significant underperformance and/or hitching presumably due to parked cores causing problems. So my question is, is there a more robust means of getting PowerShell to determine whether or not a game is currently running? I'm also open ..read more
Visit website
Return output from Invoke-Command?
Reddit » PowerShell
by /u/BearAdmin
11h ago
Hi all, I am trying to run a remote script that is on the remote computer. The script takes commands like "status" and returns the result to the console, but using inovke-command, the result does not return. Invoke-command -ComputerName computer1 -ScriptBlock {"c:\program files\red\ctrl.ps1 status"} I tried putting all this in a variable and output the variable but that only output the command. Could have done that wrong though. Thanks! submitted by /u/BearAdmin [visit reddit] [comments ..read more
Visit website
Write-Progress positioning question
Reddit » PowerShell
by /u/Mamono29a
11h ago
I'm running this command and I can't seem to figure out where Write-Progress should go. I tried at the end, $Top32 = Get-ChildItem $folder.ContentPath -recurse -ErrorAction SilentlyContinue | Sort-Object length -descending | select-object -first 32 | measure-object -property length -sum | Write-Progress "Calculating largest files in $($folder.ContentPath)..." This resulted in this error: Write-Progress : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters t ..read more
Visit website
Use of tilde (~) in Powershell
Reddit » PowerShell
by /u/Feeling_Cost_8160
11h ago
In the commandline: Invoke-WebRequest https://somefile.zip -OutFile ~\somelocation\somefile.zip What does the tilde (~) mean? Thanks. submitted by /u/Feeling_Cost_8160 [visit reddit] [comments ..read more
Visit website
Copying files from network drive using Invoke-AzVMRunCommand
Reddit » PowerShell
by /u/Jazzlike-Tear-7231
11h ago
Hi all, I'm creating a Windows golden image for my company's AVD. One step of it is connecting to network drive (Azure NetApp Files), downloading some files from it to VM and unmounting the drive. I have written a simple Powershell script (which will be executed as one job in pipeline) to copy the files. When i run it from the machine, it works flawlessly (it's being run as an local Admin account). However, when i try to run it from my computer, using Invoke-AzVMRunCommand, it looks like the script succeeds, but the files are nowhere to be found. Might this be related to the user that runs th ..read more
Visit website
What did you do with PowerShell today?
Reddit » PowerShell
by /u/Rouge_Outlaw
11h ago
submitted by /u/Rouge_Outlaw [visit reddit] [comments ..read more
Visit website
Laptop automate 1 display only.
Reddit » PowerShell
by /u/Public-Childhood-493
11h ago
I have a Windows 11 gaming laptop with two displays: an internal one and an external wired monitor capable of 165Hz. I always want to use just one display at a time. My goal is to ensure that when I'm plugged in, I use the external monitor at 165Hz, and when I'm unplugged, I use the internal monitor, switching the external one to 60Hz to conserve battery. I'm looking to automate these settings so that they adjust based on whether my laptop is charging or on battery. I'm considering setting up PowerShell scripts with Windows Task Scheduler to manage the display and refresh rate changes automat ..read more
Visit website

Follow Reddit » PowerShell on FeedSpot

Continue with Google
Continue with Apple
OR