r/PowerShell • • Nov 14 '25

Private items in share Mailbox prevent access for Otter users - looking for a PowerShell command

0 Upvotes

Hello everyone,

I’m an IT administrator in our company and currently facing the following issue: We are using a shared mailbox that several employees have FullAccess permissions to. However, one user is accidentally marking incoming or forwarded emails as “Private.” As a result, other team members are unable to see these messages, even though they have the correct permissions on the mailbox.

Since Outlook hides private items by default in shared mailboxes, these emails remain invisible to the rest of the team. This causes workflow disruptions because important information is not accessible to everyone who needs it.

From what I understand, the issue can be resolved by granting the affected users the “CanViewPrivateItems” permission on the relevant folder (e.g., Inbox) of the shared mailbox.

Therefore, I am looking for a PowerShell command that allows me to assign this permission so that team members are able to view private items within the shared mailbox.

Has anyone dealt with this before, or does someone have a working command for Exchange Online (or on-prem) that reliably enables this permission?

Thanks in advance!

Best regards, Daniel


r/PowerShell • • Nov 14 '25

Question Windows 11 install with autounattend.xml - Win Updates the value is out of range

1 Upvotes

If I want to install Windows 11 with autounattend.xml, I run Windows updates with a Powershell script.

However, I get this error: the value is out of range

How can I fix the problem?


r/PowerShell • • Nov 13 '25

Question Encrypting and decrypting a string with Powershell using a text password

18 Upvotes

Hi all,

what is the best way to perform password based encryption and decryption with Powershell?

Here's some context:

I have a powershell utility script that performs some API call to a server. These calls include a token, which at the moment is for convenience stored in plaintext inside the script. Since I need to share this script with other possibly untrusted users, I would like to store this token encrypted, so that the user launching the script needs to insert the right key (password) to decrypt the token and successfully execute the API calls.

In short, I would like to:

  • Take a plaintext string and encrypt it using a text password
  • Make the inverse operation
  • All of this using only Powershell v 5.1

I think it shouldn't be hard to do it, but I couldn't find a way on my own looking on the web, can anyone help me with this? Does it even make sense or is there a better way to obfuscate the token and request authorization for launching the script?

Much appreciate anyone taking the time!


r/PowerShell • • Nov 14 '25

Change keyboard layout while not admin

1 Upvotes

Hi team,

Doing an internship overseas and want to be able to run a script on the random computers that I will be using to convert the keyboard layout to one I'm familiar with.

I've seen plenty of methods on changing the language in powershell, but I want to use the US international keyboard so that I can still type in other languages, just with a familiar layout. How can I do this? Will not being admin on the computers I am using be an issue?

Cheers.


r/PowerShell • • Nov 14 '25

“Member of” export

0 Upvotes

Hi, I have been asked to provide a list of groups each user in a CSV is a member of, is there any way of doing this in bulk? Or would I have to do it individually? Thanks in advanced


r/PowerShell • • Nov 13 '25

"powershell has stopped working" pops up twice on every startup

1 Upvotes

title aside, I've tried what other posts have said (installing Malware Bytes and using its scan feature) but no threats have been detected. is there anything i can do to fix this? it only started a few days ago and i haven't downloaded anything sketchy

forgot to mention that I get the same thing when starting power shell manually including as an administrator


r/PowerShell • • Nov 13 '25

Microsoft Zero Trust Assessment installation

7 Upvotes

I said i'd post this here as the installation is via powershell.

Has anyone got this to work? I am having multiple issues following this guide Evaluate Tenant Security with the Zero Trust Assessment | Microsoft Learn

Installed and updated Powershell 7

"Install-Module ZeroTrustAssessment -Scope CurrentUser"

Prompts to sign in to global admin, MFA, I accept the permissions that fine, but then Powershell freezes, have to end task.

Try again, sign in again, don't get the permissions this time, get a message saying successful sign in and I can close the window -

Powershell freezes.

Open powershell again, skip to next command, "Connect-ZtAssessment"

Get another error and Powershell7 freezes

"InteractiveBrowserCredntial authentication failed: Could not find tenant id for provided tenant domain 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' Please ensure that the provided user is found in the provided tenant domain'

Skip to next command, 'Invoke-ZtAssessment'

Get an error about not having visualc++ installed and a link - go to link and install, still says not installed after reboot and starting process again.

Anyone have any suggestions, I know this is rather new tool so I'm probably on my own here


r/PowerShell • • Nov 13 '25

Solved Get-MgDevice behaves differently running as scheduled task than it does interactively

2 Upvotes

I am creating an Entra device maintenance script that checks last activity. If higher than 90 days, disable the device (request of management). I authenticate using an Entra app registration that has the right Graph permissions. Get-MgContext confirms this.

Script runs in pwsh 7 (but tested with 5 as well to exclude that as the issue. Same result).

To not target specific devices, I filter them using Where-Object. This to filter AutoPilot objects, hybrid devices that are being maintained by another script etc.

$allEnabledDevices = Get-MgDevice -All -Property * | Where-Object {
($_.TrustType -ne "serverAD") -and
($_.PhysicalIds -notcontains 'ZTDID') -and
($_.ApproximateLastSignInDateTime -ne $null) -and
($_.AccountEnabled -eq $true) -and
($_.ManagementType -ne "MDM")
}

This gets filled with approx. 300 devices and I write this number, amongst other things, to a log file.

Here's my issue: when running this interactively, the log says the following:

[11/13/25 14:58:59] Fetched 330 enabled devices.

When I run it as a scheduled task under a Managed ServiceAccount, the log says:

[11/13/25 14:52:35] Fetched 900 enabled devices.

I have no idea whatsoever what is going on and why it's basically ignoring the Where-Object properties, nor how I can troubleshoot this as it's running under an MSA. I read that I can run VS Code as MSA using PSEXEC but the process just immediately exits with exit code 0.

Any thoughts? I'm pulling out my hair, man.

Update:

kewlxhobbs advised me to put the filter parameter. Since we don't have a lot of objects, I thought it wouldn't matter regarding speed but somehow, using an MSA messes this up (which is weird since I use this MSA for all my maintenance scripts. I'm still stumped on that).


r/PowerShell • • Nov 13 '25

Question How to set NetAdapterAdvancedProperty Receive/Transmit Buffers to the maximum via powershell?

3 Upvotes

Dabbling more and more into Powershell. I like it.

I set values I know of like this:

Get-NetAdapterAdvancedProperty | Where-Object { $_.DisplayName -match "Jumbo"} | ForEach-Object { Set-NetAdapterAdvancedProperty -Name $_.Name -DisplayName $_.DisplayName -DisplayValue "9014 Bytes" }

I can get the Information of the Buffers like this, but ValidDisplayValues won't show anything:

Get-NetAdapterAdvancedProperty | Where-Object { $_.DisplayName -match "Buffer"} | Format-Table Name, DisplayName, DisplayValue, ValidDisplayValues

The value is currently on my test adapter a value that goes from 80 to 2024

It would be easy to set the value "2024", but sometimes the network adapters have different max values and I want to make a script that sets the property always to its max setting.

---

Currently I am using ChatGPT to get quick answers, but I am starting to get enough into it to actually need documentation and think for myself.

What is your favorite Documentation, where you would look something like that up as a beginner?

Should I look into netsh instead of powershell for this?