Questions tagged as ['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.
Score: 0
Johannes B. Latzel avatar
Powershell Remoting with local Administrator in Domain
cf flag

I would like to establish Powershell remote sessions to domain members by using their local administrator for authentication. Let's say I have a host called "server1" in the domain "test.local". If I connect with "test.local\myadmin" I can establish a remote session and it is just fine, but if I connect using "server1\Administrator" using the correct local admin password I get the error code 0x80090311. ...

Score: 0
PowerShell on Windows: Start-Process fails if output redirection arguments are used
rs flag

Why does Start-Process fail to find the executable (not in the path) if -RedirectStandardOutput or -RedirectStandardError are specified?

I.e.

[X:\] Start-Process -FilePath "prog.exe" -WorkingDirectory (Get-Location).Path

The program starts & executes as it should. But when I add output redirection, everything falls apart:

[X:\] Start-Process -FilePath "prog.exe" -WorkingDirectory (Get-Location).P ...
Score: 0
jrd1989 avatar
PowerShell - List WSUS Updates Needed for Each Client
cn flag

I need to provide a monthly report to our client listing the updates needed by each Windows server in our environment. Ideally, the report would list the updates for the month and the servers in my environment that need them.

My PowerShell knowledge is limited but I found some scripts (see below) and tweaked them a bit to pull the updates and the targets, but I can't figure out a way to combine this info ...

Score: 0
Invoke-RestMethod : The remote server returned an error: (400) Bad Request for PATCH request
in flag

I am working on stale device cleanup script to perform cleanup of stale devices from Azure AD tenant. I am also using graphAPI to retrieve device information Via GET request which works fine. But when I try to use PATCH/POST request to update device status, it is not working as expected and throws an 400 error message. I have tried modifying the body part and received 404 and 403 error messages as well. ...

Score: -1
user25998 avatar
Run powershell script on a remote computer using PsExec
in flag

I am using below code to run a powershell script using PsExec. But it does not seem to work. I am using Start-Process cmdlet to run PsExec using Powershell.

Start-Process -FilePath C:\tmp\PSExec.exe -ArgumentList "\\server.fqsn.com Powershell.exe '-ExecutionPolicy Bypass -File C:\tmp\email.ps1'"

Any help on this is greatly appreciated.

Thank you.

Score: -2
yogesh deshpande avatar
How to change IP address of azure NIC, as soon as azure load-balancer's health probe detect instance unhealthy?
ro flag

I have two machines in backendpool of azure LB, I would like to update network interface usign rest api as soon as health probe detects vm is unhealthy. is there any way to to recoginse that event happened and then modify network interface? is there any way we can achive this with, alert detection and executing powershell script?

Score: 0
CG Nobles avatar
Tease out extensionAttribute5 with get-mguser
in flag

Trying to force myself to start using graph thru powershell since it looks like the AzureAD powershell commandlets are going the way of the dodo at some point. Wondering if there is a way to use get-mguser to grab extensionAttribute5.

I know you have to use expandedproperties to get to the onpremextensions. You also have to use the beta schema to see the extension attributes in place. Where I'm l ...

Score: 0
stackprotector avatar
How can I set the ACL of a CA programmatically?
th flag

When launching the CA console (certsrv.msc), I can right-click on my CA, select Properties and then I can modify the ACL of my CA in the Security tab. When I modify it, the changes are applied to the AD object at:

CN=MY-CA,CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,DC=contoso,DC=com

When I view it in the ADSI editor, the modified ACL entries are not inherited, but dire ...

Score: 0
Automated download from microsoft download center
us flag

For automating the installation of Microsoft Deployment Toolkit, I need to download MicrosoftDeploymentToolkit_x64.msifrom the relevant Microsoft Download Center page.

Is there any way to easily download this msi with powershell without using heavy tooling like selenium?

Score: 1
Manu avatar
Ansible task for updating/cleaning up dbatools failing
us flag

I keep the Installation of the dbatools.io PowerShell module updated on my MSSQL Servers with a simple Ansible playbook which includes the following task:

#################### UPDATE DBATOOLS ####################
    - name: uppdate dbatools
      win_shell: |
        if ([Net.ServicePointManager]::SecurityProtocol -match "Tls12") {
            write-host "OK: tls 12 active"
            }
             ...
Score: 1
bjoster avatar
How to delete a Scheduled task folder with PowerShell?
cn flag

I need to delete a scheduled task folders on a lot of machines, ideally with PowerShell. I couldn't find anything on how to do that - it seems like the documentation covers everyting but folders.

Did I miss someting?

Score: 1
Johannes B. Latzel avatar
Windows file content not updated in Explorer/Powershell
cf flag

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 does not get updated afterwards in Windows Explorer and Powershell.

Example: A file was created on May 17th, 2022 at 0:00. It has a size of roughly 24KB in Windows Explorer and has a last write time  ...

Score: 1
user3271408 avatar
Add-WindowsCapability fails with "Source files could not be found"
cn flag

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 the RSAT tools for an offline system, I found this link: https://michlstechblog.info/blog/windows-installing-rsat-tools-online-or-offline/

I used this link to determine where/how to get the FoD DVD ISO ...

Score: 0
What's a simple way to test a connection timeout?
ec flag

I've recently increased the timeouts on all our LBs so they're consistant and I want to test that the new timeout has actually applied. Is there a simple powershell snippet or web tool which will simply keep a connection open until it times out therefore testing the timeout?

I'm thinking of something along the lines of a slow loris attack would do the trick.

Score: -1
Philip avatar
Using Set-MpPreference to schedule Windows full and quick scans doesn't work
ph flag

On a Windows 10 machine, I have been trying to set the time of virus scans using the following PowerShell commands.

Set-MpPreference -ScanParameters FullScan
Set-MpPreference -ScanScheduleDay Monday
Set-MpPreference -ScanScheduleTime (Get-Date 20:00)
Set-MpPreference -ScanOnlyIfIdleEnabled 0

Set-MpPreference -ScanScheduleQuickScanTime (Get-Date 10:00)

However, Windows Defender doesn't seem to obey an ...

Score: 0
geekygeek avatar
Why does Test-NetConnection indicate connection can be made, but I cannot visit the site?
jp flag

I need to determine whether a particular site is accessible on a particular port, given that firewall restrictions exist on the network.

If I cannot access the site on a particular port, then that means I would need to modify the firewall before proceeding. Otherwise, if I can reach the site, then I would be able to proceed with what I intend to do.

I wanted to know whether I could fetch a repositor ...

Score: 0
Michael Altfield avatar
Windows Equivalent to `sha256sum -c` (cryptographic hash, digest file, recursive integrity check, SHA256SUMS)
cn flag

What is the equivalent to sha256sum -c in Windows?

I have a set of very important files that I need to copy-to and mirror across many different types of disks in many geographically distinct locations. After relaying the contents to disk via USB, ethernet, fiber, radio, telegram, and signal fires (some of which are more reliable means of transmissions than others!), I want to check the integrity of the  ...

Score: 0
MSourbes avatar
How do I create an AD username with a dot in it via Powershell?
kr flag

I'm trying to change an existing script so that my username is firstname intial dot last name for example: John Doe's username will be j.doe Current script works (without the .) as: $firstname.substring(0,$i) + $lastname

thank you.

Score: 0
Powershell Cygwin copy data with Rsync remote as variable
cn flag

I have a problem with Cygwine's rsync. With a Powershell script I am trying to transfer directories from a Novell server to a Windows server

The path for the source is a variable that comes from a CSV file

Function CopyRsync ([string]$source,[string]$dest){   
        $sourceRoot = "root@"+$source +"/"        
        $dest = "/cygdrive/g/Shares/" +$dest

cmd.exe /C "e:\cwRsync\bin\rsync.exe" -vrts -- ...
Score: 0
AmazingRealist avatar
Validating credentials in PowerShell wont use Kerberos
cn flag

In reality I'm debugging a C# app but since the same command is possible in PowerShell I'm trying there.

I am trying to validate user accounts using the following in PowerShell:

> Add-Type -AssemblyName System.DirectoryServices.AccountManagement
> $ds = New-Object System.DirectoryServices.AccountManagement.PrincipalContext("domain", "<domain>", "<OuDN>", "negotiate", "<username&gt ...
Score: 1
Is this scenario a possible issue/bug with WINRM and IIS w/site bound exclusively to loopback address
cc flag

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 exclusively to the localhost address, 127.0.0.1. When configured in this way, using "localhost" in a browser address bar doesn't work; the connection will either be refused or reset. The site can only  ...

Score: 0
Check MS-PEAP-Certificate by opening a connection (using Powershell or any other environment)
in flag

We are running an NPS-Server on Windows Server 2016 that serves as a Radius-Server for our wifi-network. A few days ago, all clients lost the connection because the validity of the certificate in use for the MS-PEAP-Protocol ended.

Now we would like to add an automatic check that warns us before the certificate will end the next time. It should connect to the server as a normal client and check i ...

Score: 0
Joe Enos avatar
Start remote PowerShell command and have it finish even if disconnected
gb flag

If I start a remote PowerShell session with:

Enter-PSSession -ComputerName somecomputer

Then I want to execute a long-running process:

[somecomputer]: PS C:\> C:\SomeApp\DoSomething.exe

If my remote session is disconnected for whatever reason - such as a local machine network outage or reboot - is there any way to ensure that the command still completes on the server?

From what I'm seeing, it s ...

Score: 1
smwk avatar
Add Windows 10 language pack via PowerShell
cn flag

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:

enter image description here

Only the default en-us can be selected as the Windows Display Language until en-IE is downloaded. Any PowerShell commands I find only work after the pack is downloaded. From what I've found the pack will only download manually after the system (WinHTTP ...

Score: 0
BadKempachi avatar
Error while transferring file permissions
cn flag

I ran into a problem, wrote a script that compresses pdf files through a program and transfers rights to a new file by copying from the old one to differentiate access to new files. Here is the part of the code that I have is the problem

$owner = $origFile.GetAccessControl().GetOwner([System.Security.Principal.SecurityIdentifier])
             $newFile = Get-Item -Path $PathoutFile
             $Fi ...
Score: 5
Nicolas Formichella avatar
Extremely slow PowerShell operation on laptops
in flag

We have a fleet of ThinkPad X1s, running Windows 11, that are showing the same symptoms when using PowerShell (.NET Core 7.2.2 to be exact).

Very slow profile loading (Chocolatey's module tells that it takes more than 2000 ms to load, and it has been verified that Chocolatey isn't the issue) and overall responsiveness (like at least a second between command finishing and shell being ready again).

 ...
Score: 0
Azure AD Kerberos decryption key rollover; new-azureADSSOAuthenticationContext; using token instead of pscredential
ae flag

We do the 30 days kerberos decryption key rollover process automated by using an "encrypted" password stored within a text file to create the neccessary PSCredential object for the Powershell command new-azureADSSOAuthenticationContext.

This works - but I want to improve the general security and want therefore to eliminate the PSCredential object for the Global Administrator of our Tenant on Azur ...

Score: 0
PowerShell 5.1 I know this UNC path exists and I can get to it from explorer, so why error message
kr flag
Rod

Environment:
PowerShell 5.1
Windows 2016 Standard
Windows 10 Pro

I know this UNC path exists because I can get to it from Window Explorer both in Win 10 and Win 2016, so why am I getting this error?

This works fine on my Windows 10 machine but not on Windows 2016 Standard machine, smh.

COMPUTER01 here is a remote server.

$versionFolder = "\\COMPUTER01\c$\temp"
$sspLatestVer = (Get-ChildItem $versionFolder ...
Score: 0
Windows 10 Enterprise, PowerShell & logged on Domain Admin
gp flag

Some years ago I ran in to a problem where PowerShell had limited functionality when logged in as a Domain Admin. Specifically PowerShell couldn't modify the LocalMachine hive or add/delete/modify files in Program Files. My understanding was the Microsoft REALLY doesn't want you logging in as a DA. You should remote in to your servers, not log in, and no work done on a workstation should ever require Do ...

Score: 1
Read content of .sst file using PowerShell?
mx flag

How can one read the content of a .sst file uisng PowerShell? I know about Get-ChildItem and the cert drive, but how can I read from a .sst file instead of the Windows internal certificate stores?