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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
596 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 ...
Ivan Carlos's user avatar
0 votes
2 answers
197 views

How can I set an Office365 mail archive policy for all mailboxes where mails are older than 5 years and size larger than 50GB

How can I set an O365 mail archive policy for all mailboxes where mails are older than 5 years and size larger than 50GB I have looked up Office365 admin portal, however can't see any options to ...
ppau2004's user avatar
  • 163
0 votes
1 answer
85 views

RegEx passed by CSV file not working in PowerShell

Hi I have a script trying to pull out the price value from a html file. the Regex works when I assign it in the script but when I put the regex in CSV, it refuses to give me the result. Could someone ...
Cliff's user avatar
  • 3
-1 votes
1 answer
345 views

Powershell 5.1 - Get-ADUser fails to find user unless running as Administrator

I just ran into an issue I cannot explain and need help. I'm on a domain controller (as a domain admin) running Powershell 5.1. I'm searching for a specific user that I simply cannot find, but I know ...
Matthew McDonald's user avatar
0 votes
0 answers
192 views

How to restart a windows service when a log file has not been modified for a period of time?

I have a windows service and it's running a bit problematic. Sometimes it crashes or sometimes connection to the server is lost but it does nothing for it. Therefore, I have to check the logs of the ...
oktay's user avatar
  • 11
0 votes
0 answers
809 views

Scheduled Task not being deployed via GPO

I have created a FailedLogon task in GPO similar to this https://woshub.com/scheduled-task-gpo/ The task gets deployed if I run it as SYSTEM. But when trying to run it under a service account ...
imaxt's user avatar
  • 1
0 votes
1 answer
934 views

Powershell - get name and mobile from group with more than 5000 members

I need to extract the name and mobile of all users in an AD group that consists of more than 5000 members. When I previously did this I only had to extract the name, and this code solved my problem ...
Lars's user avatar
  • 3
-1 votes
1 answer
2k views

Add Network Printer using command /Powershell after exporting it from One Machine to Another Windows 10/11

AIM : To export Network Printer from one Windows 10 machine to an output file and using that output file import it to another Windows 10 machine on the same network. Research work: The following ...
Guru's user avatar
  • 3
0 votes
1 answer
173 views

Execute command on windows client from windows server

how can we execute command on CMD or power shell windows clients from a windows server or admin domain on network we are using windows server 2016 for active directory and all users have windows 10 we ...
RedOne's user avatar
  • 11
3 votes
1 answer
1k views

Import-PfxCertificate not importing to correct certificate store

I am trying to import a PFX using PowerShell, that has been created by OpenSSL from a cer and key file (the key was generated by OpenSSL along with a CSR, which was submitted to internal AD CA to ...
James Edmonds's user avatar
0 votes
1 answer
169 views

How do I reset a PowerShell build step script to use the template?

I have a build script template that does all the usual build script things: sets up a bunch of parameters, configures various config values, and runs a PowerShell script to run a build step. This ...
Mason Wheeler's user avatar
-1 votes
1 answer
98 views

AD lockout email alert script working intermittently

So we've been using this PS script for a while and was working fine until we migrated the domain controllers. The new domain controllers are running core Microsoft Windows Server 2019 Datacenter. We ...
imaxt's user avatar
  • 1
2 votes
1 answer
611 views

PS Stop-Process fails to stop a subprocess launched from cmd.exe

Preface: I've boiled down a problem I'm having to this simple reproduction, which admittedly looks pretty strange out of context. From powershell (PS), if I use Start-Process to start notepad and ...
cod3monk3y's user avatar
1 vote
1 answer
556 views

PowerShell script to write a printer name

I have a PowerShell script. This: Get-Printer | ft name,portname,location | Export-Csv c:\intel\intvprint2.csv -NoTypeInformation But it isn't any good :( I made the script, but the result is file ...
Robert's user avatar
  • 19
-2 votes
1 answer
352 views

Unusual Error on Exchange Server 2019 Enterprise

I've got my own personal Microsoft Exchange Server 2019 Enterprise at home and I recently upgraded all the VMware Guests to Server 2022, Rebuild all my domain controllers from scratch from 2012 R2 ...
Daniel's user avatar
  • 3
2 votes
1 answer
516 views

Powershell Help - Add Active Directory MemberOf to existing Script

The working PowerShell script below provides me with all the users from a specific AD Group. It also lists their Title and Department. I want to add another column that lists all of the other AD ...
mugirl73's user avatar
0 votes
1 answer
377 views

How to run PowerShell scripts remotely on old servers (2012 and 2012 R2)?

I've been running remote scripts on newer VMs (2019 and 2022) but now I have to run my scripts remotely on older VMs as well. It looks like PowerShell Direct is not available on older Windows Server ...
noobie's user avatar
  • 101
0 votes
1 answer
1k views

Error when importing certificate via PowerShell to Local Certificate Store. Missing PrivateKey Information

I have have tried the following ways to import a certificate to the localmachine store via PowerShell. The console was running as administrator. Import-PfxCertificate -Exportable -Password (secure....
Jessie's user avatar
  • 192
0 votes
0 answers
407 views

run icacls across domains - failed trust relationship

I frequently have to create Directories and set permissions on Samba-Shares which are joined to foreign Domains without Trust Relationship to my "home" Domain. Mounting and creating ...
Jochen's user avatar
  • 1
0 votes
1 answer
3k views

how to install OpenSSH Server windows 11 OFFINE, without internet connection with powershell

I need to isntall SSH server on windows 11 using powershell. It should be a script that isntalls SSH server and logs you in and does everything untill this: ssh domain\username@servername These are ...
Gaara's user avatar
  • 1
1 vote
2 answers
452 views

Powershell - how to scan Active Direcotry for nested objects?

I have some User objects with "ExchangeActiveSyncDevices" object within. I also have some Computer objects with published printers inside. So how can I look (with PowerShell) for such ...
user2838376's user avatar
-1 votes
1 answer
727 views

Remotely open PowerShell via Intune/365?

The organisation I work for have a range of different devices, mainly laptops, Surface Go and Surface Pro. We have a number of devices that we need to physically locate at our sites for servicing and ...
rgmnz's user avatar
  • 11
0 votes
1 answer
339 views

saltstack cmd.run variable expansion

I can get salt to let me run keytool this way: salt [host] cmd.run shell=powershell '& "$JRE_HOME/bin/keytool.exe" --help' But I can't figure out how to put this into a state file. A ...
robbie.huffman's user avatar
0 votes
1 answer
195 views

Custom script extension for drive letter override in Azure VM creation

I am able to run the below script within the VM without any error gwmi win32_pagefilesetting $pf=gwmi win32_pagefilesetting $pf.Delete() Restart-Computer –Force Get-Partition -DriveLetter "D"...
mysanj's user avatar
  • 1
0 votes
1 answer
368 views

Get-MailboxStatistic returns wrong data

All! I have Exchange 2013 organization: several exchange servers, multiple mailbox database. To defragment on of the MDB1 (want to reduce size), i've created new MBD2 and move all maboxes from MDB1 to ...
Posix's user avatar
  • 11
-1 votes
2 answers
2k views

Powershell sending to Teams: Bad payload received by generic incoming webhook

I try to send from within Powershell 7 (on Windows) to a Teams Webhook. If i send a formatted string, it works. If i send the same string via a variable, it brakes. Any idea? PS Microsoft.PowerShell....
Chris9834's user avatar
  • 181
0 votes
1 answer
578 views

Powershell script to export information to a CSV file

I am trying to figure out why Business Phone is not populating in the report. Any assistance with be greatly appreciated # Connect to AzureAD Connect-AzureAD # Get all Azure AD users $AzADUsers = ...
Chris's user avatar
  • 1
1 vote
1 answer
1k views

replace with regular expression in azure devops

I want to take this buildVariable Build.SourceVersion which will equal for example: 0gc58d92d905d62415b8866g3f48f17416da426s And replace from digit [7] till line end with empty string 0gc58d92 I ...
Shnbook's user avatar
  • 11
0 votes
2 answers
2k views

When Ansible initiates a PowerShell script, how to get Ansible to return "ok" (nothing changed)?

Usually when Ansible kicks off a PowerShell script with win_command/win_shell/win_psexec, as long as it doesn't run into errors it'll return "changed", because of course it doesn't know what ...
jerdub1993's user avatar
0 votes
1 answer
2k views

Unable to install printer driver using pnputil

I am trying to install multiple printers on a print server, however before that as a pre-requisite I have to add the printer drivers for which I am performing below steps but I am unable to view the ...
Ishan Sharma's user avatar
1 vote
1 answer
608 views

windows PC configuration: force logout/ kill existing sessions on restart

As part of our PC Build ,configuration and deployment process, we use Window Deployment toolkit and WCD (windows configuration designer) to setup 4 users with different access. Some users are in kiosk ...
shelbypereira's user avatar
1 vote
3 answers
7k views

Enter-PSSession: receiving access denied on non domain remote server

I am struggling to open a remote PS session on a remote server (Windows Server 2022 Standard). The remote server is not part of a domain. When running the command Enter-PSSession -ComputerName ...
Abid's user avatar
  • 135
0 votes
2 answers
133 views

Executable file to hide credentials

is there any software that can be used to pack credentials into an EXE file and hide them? The executable file should then start a PowerShell script with the stored access data. I saw something like ...
CptRetro's user avatar
1 vote
1 answer
218 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 ...
Roman's user avatar
  • 425
1 vote
1 answer
2k views

Storage Spaces with Azure Disk: how can we extend virtual disks?

We have on Azure several Windows Server 2019 virtual machines whose data disks are configured with Storage Spaces. How can we extend a virtual disk configured for simple redundancy (NumberOfDataCopies ...
aledeniz's user avatar
  • 213
0 votes
0 answers
2k views

How to download the SSL certificate from a website using PowerShell?

I want to download an SSL certificate using PowerShell I glad for any help
netanel shteren's user avatar
1 vote
0 answers
408 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 ...
yildizabdullah's user avatar
0 votes
1 answer
844 views

How to handle characters that need UTF-8 on XML retrieved from HTTP GET on powershell?

I am not able to retrieve data under UTF-8 encoding, through a HTTP GET request on powershell. Code: $headers_tables=@{} $headers_tables.Add("content-type", "application/xml; charset=...
marafado88's user avatar
0 votes
1 answer
98 views

How to save/print a powershell terminal text in the end of a script run through powershell commands?

I've a script that needs user inputs, and also let them check all the data being displayed, while script is running, and in the end, save/print all the content, to a file, through powershell commands. ...
marafado88's user avatar
0 votes
0 answers
221 views

PRTG PowerShell Remoting Requirements for Custom EXE/Script Advanced Sensor

I've created a script for checking the TLS certificate assigned to an SMTP Relay server which supports SMTPS. The code is available here if that's of interest. The documentation says that powershell ...
JohnLBevan's user avatar
  • 1,312
0 votes
2 answers
476 views

can't automate the authentication process with PowerShell on Linux

On Debian 11, I have installed PowerShell 7.3.0. I am testing if I can run commands on a remote Windows computer. This is a simple example to get the remote computer hostname. #!/usr/bin/env pwsh $...
aristosv's user avatar
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\...
Henry_Parker's user avatar
0 votes
1 answer
923 views

Accessing more properties of Local Security Policy with powershell

I want to modify any property that is in secpol.msc > Security settings > Account Policies. Microsoft unfortunately only gives support for a few of them, so there are still properties that I can'...
Nuro007's user avatar
  • 101
1 vote
0 answers
427 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 ...
MrDeanosupreamo's user avatar
-1 votes
1 answer
1k views

Stop and Start IIS Website remotely using WMSVC

We have configured access to a web site on a remote machine using the guide here. This lets us access the remote web site using WMSVC. The end goal though is we want to be able to connect to the site ...
Element Zero's user avatar
0 votes
0 answers
147 views

Adding a group to a folder structure "basing" on another existing group's rights

thanks for reading this wall of text anyways. My scenario: i have a mega-folder called Projects. Every subfolder is a different project. So, for example, i have Projects\N123456 - New Coca Cola. Now, ...
Claudio Ghirardi's user avatar
0 votes
1 answer
809 views

I want to use openssl pkcs12 to convert lots of pem files into pfx files - but is it possible to pass in a password via the command line?

I want to use openssl pkcs12 to convert lots of pem files into pfx files - but is it possible to pass in a password via the command line? I have quite a lot of pem files: So I want to enter a ...
Paul H's user avatar
  • 277
0 votes
1 answer
1k views

I cannot get an otherwise functional Powershell script to run on a schedule

Environment: Server 2019 Domain Controller. I have a simple script that combs through my AD users and disables anyone who hasn't logged in within the past 35 days (org policy). Looks like this: Get-...
The ITea Guy's user avatar
1 vote
1 answer
639 views

Why cannot I map an DSF/SMB share using New-SmbGlobalMapping?

I've got a DFS folder: \\my.domain\Storage$ I'd like to map it to a particular Windows Server Core machine using the New-SmbGlobalMapping PowerShell command using specific credentials. Alas, when I ...
MBender's user avatar
  • 381
0 votes
0 answers
3k views

Connecting to remote server failed: The WinRM client cannot process the request

I am trying to execute a powershell script on a remote server from my local machine, however I get an error. Here is the full error message: Connecting to remote server failed with the following ...
Unbuckle's user avatar

1 2
3
4 5
83