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
25 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 "...
0 votes
0 answers
6 views

Scheduled task with powershell won't restart when the script fails

Scenario I want to invoke a rest api on daily basis with some retry mechanism in case the rest api is not available Problem Even when the action exits with a non zero exit code, it is not restarted. ...
  • 101
1 vote
1 answer
26 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 votes
0 answers
9 views

Teams message from Powershell not formatting correctly

I have a powershell script that grabs text from the robocopy results and then sends that to a Teams channel. The issue I'm facing is getting the formatting to look correct in Teams. It appears some of ...
  • 1
0 votes
2 answers
40 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 ...
0 votes
1 answer
23 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 ...
  • 3
-1 votes
1 answer
16 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 ...
-1 votes
0 answers
17 views

How to get SAM account name from displayname or the description through power shell

i know this is little old question. Earlier someone posted the answer, as i do not have any option to clarify on that answer, i am posting this question again. In "(get samaccountname from first ...
  • 1
-1 votes
0 answers
30 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 ...
  • 1
0 votes
0 answers
16 views

vmware tag and description

i have created some tags with description in vcenter like TAGS DESCRIPTION AppOwner Brad pit APpOwnerEmail AngenilaJolie@somemovie.com Environment NIIT-UAT and attached to a ...
  • 21
0 votes
0 answers
24 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 ...
  • 1
0 votes
0 answers
16 views

Issues with robocopy /xf switch when using a variable for the /xf in powershell

I've got a cleanup job that is running daily to clean a number of directories based on a csv file. The CSV file contains the following: SourceFolder,MinAge(Days),SubDirectories(Y/N?),ExcludeItems TEST,...
  • 1
0 votes
1 answer
47 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 ...
  • 3
-1 votes
1 answer
121 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 ...
  • 1
0 votes
1 answer
39 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 ...
user avatar
3 votes
1 answer
86 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 ...
0 votes
1 answer
50 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 ...
-1 votes
1 answer
54 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 ...
  • 1
1 vote
1 answer
80 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 ...
1 vote
1 answer
227 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 ...
  • 19
-2 votes
1 answer
81 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 ...
  • 3
2 votes
1 answer
82 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 ...
0 votes
1 answer
45 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 ...
  • 101
0 votes
1 answer
148 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....
  • 182
0 votes
0 answers
35 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 ...
  • 1
0 votes
1 answer
119 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 ...
  • 1
1 vote
2 answers
58 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 ...
0 votes
0 answers
59 views

PowerCLI, Invoke-VMScript cannot get the script's exit code

I have a PowerShell scripts that uses PowerCLI's "Invoke-VMScript" command to start scripts on a sequence of systems. If the script on the first server fails, the controller script should ...
-1 votes
1 answer
80 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 ...
  • 11
0 votes
1 answer
78 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 ...
0 votes
1 answer
57 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"...
  • 1
0 votes
1 answer
70 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 ...
  • 1
-1 votes
2 answers
431 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....
  • 141
0 votes
1 answer
220 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 = ...
  • 1
1 vote
1 answer
252 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 ...
  • 11
0 votes
2 answers
278 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 ...
0 votes
1 answer
333 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 ...
1 vote
1 answer
154 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 ...
1 vote
3 answers
944 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 ...
  • 125
0 votes
2 answers
50 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 ...
0 votes
1 answer
86 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 ...
  • 403
0 votes
1 answer
244 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 ...
  • 193
0 votes
0 answers
304 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
1 vote
0 answers
142 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 ...
0 votes
1 answer
289 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=...
0 votes
1 answer
30 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. ...
0 votes
0 answers
40 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 ...
  • 1,182
0 votes
2 answers
127 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 $...
1 vote
0 answers
20 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\...
0 votes
1 answer
237 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'...

1
2 3 4 5
82