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.
1,022
questions with no upvoted or accepted answers
2
votes
2
answers
3k
views
Email reset password in Office365 using powershell
When I reset a password in the Office 365 Admin portal, I have the option to send the new password in an email, without me even seeing the password first.
I know I can reset the password with
Set-...
2
votes
1
answer
1k
views
Stop automatic reboot with gpedit shutdown script in Windows 2k8
I am search for a way to validate and maybe stop an automatic reboot under windows.
E.g. automatic reboot is initialized by windows update.
When adding a shutdown script with gpedit this script gets ...
2
votes
2
answers
3k
views
Certreq -retrieve can't find the specified CA
I'm currently writing a Powershell script and have run into a bit of a roadblock. Basically, the script requests, approves, and retrieves new certificates from our CA using certreq.exe and certutil....
2
votes
1
answer
2k
views
Powershell 2.0 : issue import-Module in a background job
I launch a script in backgroung using Start-Job command.
In this script, I load a module using Import-Module. The job stay blocked in the running state at the Import-Module step.
The same behaviour ...
2
votes
1
answer
5k
views
How can I retrieve the device information?
From Windows Server 2012 R2, how can I retrieve a device's vendor name and model number without physically opening the machine? For instance, PCI cards.
Get-WmiObject Win32_PNPEntity returns a bunch ...
1
vote
1
answer
51
views
How to implement virtual UNC mapping in a Windows user session?
I need to implement virtual SMB UNC mapping in a Windows user session.
Similar to what "NET USE H: \\realhost\share" command does, but redirect "\\virtualhost\share" to "\\...
1
vote
0
answers
73
views
Powershell Duplicate Headers Error
Hi I have a PS script that is giving me this error when it gets to a sheet with duplicate headers.
Duplicate column headers found on row '1' in columns '12 53'. Column headers must be unique, if this ...
1
vote
0
answers
131
views
Why am I only seeing logoff, but no login, events in Windows Event Logs?
I want to audit when every user logged into of logged off a server via RDP. When I run Get-EventLog or Get-WinEvent and filter for Login (Event ID 4624) and Logoff (Event ID 4634) events, I only am ...
1
vote
0
answers
390
views
PowerShell - Failure to load built-in modules due to software restrictions
Yesterday, I was working with PowerShellEditorServices to develop a tool. Internally, it uses named pipes to communicate between the client and server. They are both running locally.
At some point, ...
1
vote
0
answers
70
views
Set-DnsServerCache: Failed to connect to DNS server
I am trying to change my computer's DNS cache max time to live.
It is not in any domain, I am the full administrator on the computer - built-in administrator account + disabled group policy "Run ...
1
vote
0
answers
44
views
ISO not booting using powwercli
Using below codes I am able to mount ISO to the CD drive of a VM and change the BootOrder of the VM
$CloneVM = Get-VM -Name "999_SW999OSTest_Clone"
$IsoPath = "[NPROD_LUN-01_DEV_3333] ...
1
vote
2
answers
148
views
Odd behavior between Outlook client-based automatic reply forwarding and Exchange Powershell
At my current company we're running an on-prem Exchange 2016 email server, and when we have to manage email forwarding for employee absences in certain departments that need coverage, we have users' ...
1
vote
0
answers
468
views
How do I get a complete list of all Windows AD computer accounts that are part of a cluster group in my AD domain?
Regardless of whether they are active nodes or passive nodes, how do we get a list of all Windows AD computer accounts in a cluster group?
Using the PowerShell module: https://learn.microsoft.com/en-...
1
vote
1
answer
2k
views
PowerShell commands to manage NPS Radius policies?
Are there PowerShell commands for managing NPS RADIUS policies?
I see commands for RADIUS clients (Get-NpsRadiusClient; etc), but nothing for the policies, I can't find a command to create the NPS ...
1
vote
0
answers
78
views
Why does Application event log get cleared when I remove this custom even log
I am using powershell cmdlets to create a new event-log, register a source and log events.
I experience some unexpected behavior. I created a new log with an arbitrary name by issuing the command:
New-...
1
vote
1
answer
886
views
Windows Feature Update Silent Install
We are trying to push out the latest Windows Feature update via our RMM but when running it doesn't appear to do anything. We've tried running the following:
PowerShell
Start-Process -FilePath "...
1
vote
1
answer
620
views
Unable to create a script that list shared link for SharePoint that I am not owner or member
I am looking for a script that lists all shared links for one (or all) SharePoint sites, got one that you can specify the site, put your credentials and it generates a CSV report. Works fine, but I ...
1
vote
1
answer
227
views
Is WinRM/PSSessions using TrustedHosts less secure than DCOM (or whatever classic Windows remote access is)?
I have forever been accessing remote machines with things like file shares (\\serverName\share) and using Powershell commands that use a -ComputerName parameter. If I do this for a machine in a remote ...
1
vote
0
answers
413
views
Remote shutdown with a shutdown reason code
I'd like to power off a remote machine by Stop-Computer command in PowerShell. Is there any way to send a shutdown reason code (like Hardware: Maintenance (Planned)) as if choosing during local ...
1
vote
0
answers
30
views
OneDrive, can you migrate shared locations from one computer to another?
We are migrating users to new computer, and they have around 10 different SharePoint sites. Is there a way to copy the settings to a new computer, without manually doing so.
I've looked at Computer\...
1
vote
0
answers
444
views
Understanding how windows server storage spaces physical disk redundancy works dependent on where its configured
Im tasked with configured a windows server to used tiered storage using the following disks
4x 900 GB SSDs
10x 2.2TB HDDs
The SSD tier would be configured using parity with 1 redundant disk and the ...
1
vote
0
answers
784
views
Windows test network folder permissions for another account
How to test that an account other than login account has access to a network folder ?
Here's an example :
I'm logged in as steves but I need to test if joej has access to :
\\contoso\dept\finance\...
1
vote
0
answers
492
views
Compliance search initialization for "task search1" failed with exception: Object reference not set to an instance of an object
I've a script to start a Search task on Content Search, of Compliance.
If I use my own user account to login, I am able to run it, but if I use an unattended login through an App, like the one of App-...
1
vote
1
answer
1k
views
how export get-vm info to csv file in PowerShell?
How can I export this output to csv file ?
I have this output from below get-vm command:
Get-VM | Select Name, PowerState, GuestId, @{N="VM Config File";E={$_.extensiondata.config.files....
1
vote
0
answers
2k
views
Only 2 cipher suites are offered by Powershell Invoke-WebRequest
I am performing a Invoke-WebRequest to a site using Powershell. And i'm facing error "Could not create SSL/TLS secure channel"
PS C:\Users\admin> Invoke-WebRequest -URI https://...
1
vote
1
answer
392
views
How to make PowerShell read from a pipe?
I need to make PowerShell on Windows Server 2019 to read from a (not named) pipe and launch the commands it reads, so I'll be able to launch multiple commands on the same shell, even without knowing ...
1
vote
0
answers
606
views
Managing WSUS with Powershell. How to remove an automatic approval rule?
I'm writing Powershell scripts to manage WSUS. One script can create, read, and update automatic approval rules. But it can't delete rules.
WSUS allows admins to make rules with duplicate names. If ...
1
vote
0
answers
369
views
Create a New-PSDrive with username and a blank password
I have disabled the blank password restriction in the group policy.
I'm unable to create a PS-Drive without the password with just code and no user inputs.
$user = "Admin"
$creds = New-...
1
vote
1
answer
320
views
Creating Zip Using Foreach in PS Produces Nothing
I have a little use case where I need to zip each directory within a directory (the subdirs are flat, so no worry about recursion) and attempting to do so with a simple one liner in PS has produced ...
1
vote
2
answers
1k
views
How to Delete CRL Files in Local Cert Store
I need to import CRL files to a Bastion server that is not part of my environments domain. The CRL files are updated every few days so a new copy needs to be imported to the local cert store on the ...
1
vote
1
answer
3k
views
Search Active Directory by Canonical Name
The Manager field for contacts stored in Active Directory holds the CanonicalName of the manager's AD object, not the username or DistinguishedName. I need to be able to search AD for the manager of a ...
1
vote
0
answers
182
views
Change Windows Store Apps language using poweshell or unattend.xml?
I am trying to create a golden image and I can't find any way to set Store Apps language.
These are the settings I want:
Windows Display: English (US)
Apps & Websites: English (US)
Regional Format:...
1
vote
1
answer
158
views
Windows file content not updated in Explorer/Powershell
On a Windows Server a logging tool writes .log files to disk continuesly and rotates log files daily at midnight. Every day the new log file gets created, but almost every day its content / meta data ...
1
vote
0
answers
3k
views
Add-WindowsCapability fails with "Source files could not be found"
I am trying to install RSAT on some Windows 10 systems that have no internet connectivity. Two of the Windows 10 systems are 20H2, and one of them is 21H2. All three have the same problem. To install ...
1
vote
0
answers
306
views
Is this scenario a possible issue/bug with WINRM and IIS w/site bound exclusively to loopback address
I believe I have discovered a very strange, narrow issue relating to an interoperability problem with IIS and WINRM exercised by Powershell on Windows 10.
I have a device that has an IIS site bound ...
1
vote
0
answers
3k
views
Add Windows 10 language pack via PowerShell
I'm trying to add a language pack to existing Windows 10 builds (mostly 20H2) but the language is only available and not downloaded as per the screenshot:
Only the default en-us can be selected as ...
1
vote
0
answers
171
views
Azure VM Managed Disks Drive letters
I have a VM which has Windows OS Disk + More Managed Data Disks attached to it. Another azure VM has similar structure. I am trying to Automate Assign Drive Letter in another VM.
I checked Get-Disk, ...
1
vote
0
answers
1k
views
WebAdministration provider is not available on Windows Server 2016
Here is a puzzling issue. On some Windows Servers in my organization, if I try to run Get-WebSite in PowerShell, I get the following output:
PS C:\Users\me> Get-Website
Attempting to perform the ...
1
vote
0
answers
396
views
Registry Key disappearing on reboot after added to read application and services logs via WMI
I have a Windows Server 2019 VM and am trying to collect some specific Windows Event Logs using Get-WmiObject
In order to read an Event Logs channel in Applications and Services, I created a registry ...
1
vote
0
answers
692
views
How to export the details of a digital certificate (.cer file) to a csv file using powershell?
I have a digital certificate that I'm using for a specific task. I need to export the details of the certificate such as the serial number and issuer to a csv file that is already on my computer using ...
1
vote
1
answer
815
views
Running remote commands on Windows 10
Recently i was trying to research deeper into running remote commands from windows to windows. It can be easy with ssh, ftp - but I wanted it to run the commands without knowing the password either ...
1
vote
0
answers
712
views
How can I tell when Docker Desktop has started in a PowerShell script?
I want to write a PowerShell script that will create a number of running docker containers on boot of the machine. The problem I'm running into is that despite the com.docker.service service running, ...
1
vote
0
answers
509
views
New-CimSession from outside domain
How can I initiate a new CIM session to a Windows server in my domain, from a PC that is not in the domain? I know this works, because I did it recently from the same computer, but I always forget the ...
1
vote
0
answers
163
views
Task Scheduler GPO for purging files does not apply due to OneDrive
I am trying to create a task with the following PS script:
$locations="$env:userprofile\Desktop\New folder (2)","$env:userprofile\Desktop\New folder (3)"
$Daysback = "-30"...
1
vote
1
answer
7k
views
How to execute powershell scripts from MDT?
I have created MDT environment with PSD Extension by following these steps.
There is a default step for running a powershell script(Configure).
I duplicated that and created Configure1.
And created ...
1
vote
1
answer
229
views
Retrieve parent folder size for each IIS site
Im trying to get a list of sites from IIS (8.5) to include the folder size but cant get this to work.
Below is the current code i have that is working without the size
Import-Module webAdministration #...
1
vote
0
answers
2k
views
Calculate Size of Azure Storage Accounts & Containers Using PowerShell
I have limited knowledge of PowerShell but I'd like to calculate the total size (in GB) of each storage account, or each container in my storage accounts. I have multiple storage accounts and ...
1
vote
0
answers
227
views
Adding multiple virtual switches to New-VM?
I'm working on a Powershell script to create new virtual machines as part of a migration between a Hyper-V server running Hyper-V Server 2012R2 and a new Hyper-V server running Hyper-V Server 2019.
...
1
vote
0
answers
474
views
WDAC policy not accepting MS signed DLLs
I'm working on WDAC / windows defender application control policy. Around 80% of what I have left is from system32 DLL files, hundreds of them. Windows 10 client systems, mostly 20h2.
The base policy ...
1
vote
0
answers
796
views
Ansible powershell scripts not working - script is not recognized as the name of a cmdlet
I'm trying to stop windows services using ansible but I get the error 'script is not recognized \r\nas the name of a cmdlet."
Here is the task in the Ansible yaml file:
- name: Check if ERL is ...