Questions tagged [powershell]
An interactive shell, scripting and programming language, and surrounding environment from Microsoft. Commonly used by system administrators managing Microsoft software (including Windows, Exchange, SharePoint, and cloud services Azure and Office 365), PowerShell is included by default with Windows, and takes over from previous languages such as VB Script.
4,195 questions
1 vote
0 answers
103 views
Winrm cannot complete the operation from one server to another, but can connect to others
Not a duplicate of https://stackoverflow.com/questions/39917027/winrm-cannot-complete-the-operation-verify-that-the-specified-computer-name-is Also, I posted question in StackOverflow here: but it ...
1 vote
0 answers
81 views
Get AD FS Relying Part Signature Certificate expiration within powershell
I'm working on automating some certificate rotation tasks. Specifically, we still have some applications using AD FS SAML authentication, and so I'm converting this to use powershell run by a ...
0 votes
2 answers
169 views
Handle csv file - add value with mapping table
A script generates a csv-file: User | actualValue | user01 | actualValueB | user02 | actualValueC | user03 | actualValueB | user04 | actualValueA | user05 | actualValueA | . . . The file has the ...
-1 votes
1 answer
123 views
How to find overlapping or conflicting GPOs
We have 600 GPOs. I want to find policies that have the same or duplicate settings. How can I do this? Thank you.
1 vote
1 answer
101 views
DFSRDIAG backlog and Get-DFSRBacklog fail with access denied when run via PSSession
From an elevated Powershell session on either source or receiver, I can successfully run: dfsrdiag backlog /smem:source /rmem:receiver /rgname:"Group" /rfname:"Folder" However, ...
1 vote
1 answer
100 views
How can I uninstall/remove these services from some of the domain devices using automation?
I manage about 300 Windows devices in an Active Directory domain. Some endpoints have unauthorized applications installed that are generating a high volume of tickets for our team and causing heavy ...
1 vote
1 answer
132 views
Users with privileged roles on administrative units
I need a list of Entra users in my tenant who can assign themselves privileged roles. I need the RoleName, UserName, AssigmentType (for general, not if it's pimmed at the moment the script runs) and ...
0 votes
1 answer
378 views
Windows Admin Center fails to install with error: Failed to configure PowerShell Remoting. Error: Access is denied
I am attempting to migrate a local Windows server (2016) to a new local server (2022) using Windows Storage Migration Service. While installing Windows Admin Center ("WAC"), I encounter the ...
1 vote
1 answer
133 views
Azure "Run Command Script" Invoke SQL on new SQL Server VM using "NT AUTHORITY\SYSTEM"
I deploy SQL Server 2022 Azure VM's on a regular basis. I want them to be pre-configured with a series of company standards (the details are not that important just know that this involves restoring ...
0 votes
1 answer
151 views
"Get-ADDomainController -Filter *" fails with "Directory Object Not Found"
This happens on our forest DCs, but not on our child domain DCs. From the forest DCs, I can run Get-ADDomainController -Filter * -Server , but I can't do it the other way around. From either domain, I ...
3 votes
1 answer
228 views
How to fix Powershell script when it says "mdf, ndf and ldf already exist"
I have a PowerShell script producing the error below: Set-DbatoolsInsecureConnection -SessionOnly Get-ChildItem "F:\WH_BEE\FULL\WH_BEE_FULL_$(Get-Date -Format "yyyyMMdd")_*.bak" | ...
0 votes
3 answers
227 views
Migrate Windows File server keeping NTFS and share permissions (not robocopy or xcopy)
I need to copy all files from an old file server to a new file server on the same local network and preserve all permissions associated with every file. I have done this operation once successfully. ...
0 votes
1 answer
57 views
How do I edit a remote file as administrator that swaps out a part of an existing string with a different partial string
I need to edit files on multiple systems that require RunAs administrator. I have been working on a script to ensure the command works. I can run the script. My original attempt would modify the ...
2 votes
1 answer
103 views
Weird Windows copy / paste issues - leading spaces
I'm working on a large-scale unstructured data project in my org, and there's a number of very large volumes which need to be relocated that have thousands of folders (which are named 0000000 - ...
0 votes
1 answer
343 views
Convert Windows ETL file to text logs
How do I convert an ETL trace to readable text that contains all the (fully-resolved) log strings within? e.g. I'm trying to get all logs from all Microsoft-Windows-Bluetooth-* providers. (The ETL ...
1 vote
0 answers
55 views
BackupExec / BEMCLI / Issue creating Backup Job with Selections from multiple servers
Using PowerShell and the BEMCLI module, $f01 = New-BeLinuxMacSelection -Path "/somethingA/*" -Recurse $g01 = New-BeLinuxMacSelection -Path "/somethingB/*" -Recurse $selection1 = ...
0 votes
1 answer
212 views
Is it possible to disallow all interactive PowerShell usage, but still allow script execution?
Is it possible to allow running of PowerShell scripts, (which we have controlled via AppLocker) but completely forbid the use of an interactive PowerShell prompt? Ideas I've tried: AppLocker. We do ...
2 votes
1 answer
578 views
Delete all E-Mails from Exchange Online Mailbox (all content)
We have a EXO mailbox, where E-Mails are collected for a special business process. This works fine, but the process-tool is not able to delete messages. So the mails are piling up. Around 100k E-Mails ...
0 votes
0 answers
57 views
O365 to O365 tenant to tenant migration, Can't Assign ArchiveGUID "used by another recipient object"
I'm trying to migrate some mailboxes from one O365 tenant to another (no hybrid/on-prem involved). Using this guide I've got endpoints set up and the app authorized on both sides, all my mailboxes ...
0 votes
2 answers
131 views
Powershell Invoke-Sqlcmd Issue - DB in Single User Mode but can't restore DB
I've been trying to figure out what's going on and I'm at a loss. Hoping someone can help! I have an Azure Pipeline that's using a self-hosted agent. The overall goal is to be able to restore SQL ...
0 votes
0 answers
105 views
How to find out the free space available in my mapped drive in Azure for my SQL Server backups?
I backup my SQL Server to an Azure location. The way I do this is by mapping the Azure location as a drive in SQL Server and then direct my backups to that location. When I run the following script I ...
0 votes
1 answer
180 views
How can clients connect to an SMB shared printer UNC with Powershell?
When running: Add-Printer -ConnectionName \\server\printer-share it reports an error: Add-Printer: Alternative user credentials are required to access the specified resource. In line: 1 Add-Printer -...
5 votes
2 answers
423 views
WinRM Certificate authentication fails with 401 error on Windows Server 2022
I have an issue with WinRM certificate authentication on a Windows Server 2022 CIS STIGs image. The server is running the WinRM service, and I'm connecting from an Ubuntu Pro 20.04 FIPS client using ...
0 votes
0 answers
78 views
Powershell command to activate Forta Frontline Agent with PSAppDeployToolkit 4.0.6
I'm working on deploying the Forta Frontline Agent using the PSAppDeployToolkit 4.0.6. I've set up the deployment by creating a new ADT template, placing the MSI installer in the appropriate directory,...
0 votes
0 answers
57 views
Powershell computer startup script failing
I'm hoping someone can point me in the right direction here as I've spent days searching and trying everything I can find to no avail. I've setup Windows LAPS in a new domain and having done this ...
0 votes
0 answers
234 views
Trouble using Powershell's New-PSDrive
In order to automate installations of software that can do unattended installs, I wrote a simple PowerShell script that gets my administrator credential, creates a new drive with New-PSDrive pointing ...
0 votes
1 answer
117 views
Starting Network Script in Task Scheduler as System with FQDN not working
i have a strange Problem and i hope someone can help me. What I’m doing: I am creating a Scheduled Task via GPO, which starts a Powershell script which is located on a network share. The Script should ...
0 votes
1 answer
385 views
Script to update applications through WinGet is not running through GPO
I wrote the following script in PowerShell to update applications through WinGet and force-uninstall and reinstall if the update fails: <# .SYNOPSIS Installs the Powershell WinGet client module....
1 vote
1 answer
123 views
How do I Upgrade PowerShellGet Behind a Corporate Firewall?
I am trying to upgrade PowerShellGet from version 1.0.0.1 to a newer version on Windows Server 2019. I am not an expert on NuGet, but have a rudimentary understanding of package providers and package ...
0 votes
0 answers
188 views
Fully Unattended Installation of Windows 11 with User-Specific Customizations (Chocolatey, Visual Studio Code Extensions)
I am currently setting up a fully unattended installation of Windows 11 using a USB flash drive. To do this, I am using the Schneegans-Generator to create the necessary XML file. In this file, I’ve ...
1 vote
0 answers
133 views
Importing .pfx certificate to NTDS/Personal store remotely
I've encountered a problem where I need to import a .pfx certificate to a remote Windows Server running LDAP to it's NTDS/Personal store. I found this https://awakecoding.com/posts/active-directory-...
0 votes
1 answer
333 views
How to get verbose output for intermittent TLS handshake failures?
An application owner is having issues connecting to a web service. The application in question is in ASP.NET running on IIS, but I have reproduced the problem using PowerShell using the following: $...
0 votes
0 answers
122 views
Error running Add-NetNatStaticMapping command to open ports to VM
I routinely run the following command via PowerShell (in Administrative mode) to open ports towards a VM and today, creating a new VM from a template (as I have always done) I got the error below. The ...
0 votes
0 answers
264 views
Trying to run Podman machine to use with Azure devops build agent - Failed to configure network (networkingMode Nat), falling back to VirtioProxy
I have a local On-Prem Azure Devops instance with Windows build agents I'd like to utilize Podman from these Windows build agents so that I can utilize Podman inside my Azure Devops pipelines. I am ...
0 votes
0 answers
94 views
Moving AD objects between OU
We are upgrading Windows 10 to 11. I am trying to automate moving workstation objects between two OU's, however the script does not catch anything. Import-Module ActiveDirectory $SourceOU = “OU=Win10,...
0 votes
1 answer
142 views
PowerShell/Active Directory Web Services performance issue only on specific domain controllers
Last week my team noticed some of our PowerShell AD Group management scripts throwing errors. After a little digging, we found that the 'Get-ADGroupMember' command was timing out when pointed to ...
1 vote
2 answers
304 views
get-pfxCertificate fails on a valid certificate, whereas import-pfxcertificate works
I have a known-good PFX file, with the correct password. I can import it using the windows certificate UI, or the import-pfxcertificate cmdlet. However, get-pfxcertificate fails. Any ideas? PS > $...
0 votes
0 answers
943 views
WinRM is not working
After I changed a Windows Server 2019 host name, WinRM stopped working. I found that the instances of WinRM are still attached to that old host name. So I ran both commands to remove HTTP and HTTPS ...
0 votes
1 answer
557 views
PsExec launch remote program as same user name without a domain
I'm trying to launch a remote program with PsExec. I have it mostly working, it works if I specify the user name and password or I run as SYSTEM account. I want to omit the user name and password, so ...
0 votes
1 answer
187 views
Why does Powershell Where-Object not find an exe that is on the path? While where.exe succeeds
In PowerShell, where.exe finds the thing I'm looking for. Where-Object does not. Why? PS C:\Users\dpchi> where wget.exe PS C:\Users\dpchi> where.exe wget.exe C:\ProgramData\chocolatey\bin\wget....
0 votes
1 answer
138 views
Get list of last logged users from AD OU
I am trying to get a list of last logged in users using PowerShell. I tried the following, but doesn't reveal the user: $ou = "OU=MyOU,DC=test,DC=com" # Get computers from the specified OU $...
0 votes
1 answer
193 views
Powershell function() without pararmeter args
In Powershell it looks like the parameter list to a function is an array constructor, but sometimes () is allowed and sometimes not, for instance when calling the overloaded getHashCode() function. ...
0 votes
0 answers
48 views
Set-CMTSStepConnectNetworkFolder and Set-CMTSStepApplyNetworkSetting error "Cannot access a disposed object"
"Cannot access a disposed object" is the error when running two commands in PowerShell to change the task sequences entries for an OSD. For example: Run this command with the correct ...
0 votes
1 answer
94 views
Output from computer info Powershell script: convert from columns to rows in csv
I have to be missing something obvious, this task shouldn't be this hard! Thanks in advance if you can point it out to me without laughing too much. I'm writing a system survey script, to run on each ...
1 vote
0 answers
285 views
Install certificates in MDT task sequence
I am using a deployment task sequence to call a Powershell script to install multiple certificates, but it is not installing them. I am using the following in the Power Shell Script: Import-...
1 vote
1 answer
1k views
PowerShell Constrained Language Mode doesn't work within scripts
I have an AppLocker policy that allows only scripts signed with a certificate from my company. This is the only script policy, no default created. When I run a Windows PowerShell 5.1 or PowerShell 7 ...
0 votes
1 answer
750 views
Windows DNS server list all records all zones containing CIDR
From powershell, I can run Get-DnsServerResourceRecord -zonename "test.com" to get all records in the zone. I can load all zones to a variable, and use a for loop to get all records in all ...
0 votes
0 answers
40 views
Terminate the local powershell session when an interactive psremote session is closed
I have a jumphost from which people can log in to remote computers without knowing the passwords to remote computers. I can create a remote session using following: $session = New-PSSession -...
1 vote
1 answer
246 views
HPE iLO | Delete SSL Certificate w. PowerShell
I have about a hundred servers that i need to do a repetitive process on. Disable DHCPv4DomainName & DHCPv6DomainName Set DNSName Set DomainName These are easily achievable by use HPEILOCMDLETS ...
1 vote
1 answer
380 views
Get domain local group membership of another domain in the same forest
My Active Directory Forest consists of multiple child domains, including: Main domain (main.contoso.local) Test domain (test.contoso.local) My user [email protected] is member of group MAIN\...