PowerShell is a cross-platform command line and scripting utility from Microsoft. Use this tag for questions about writing and executing PowerShell scripts ONLY. Programming questions specific to the cross-platform version PowerShell Core (Windows, macOS, and Linux) should be tagged [powershell-core]. Questions about system administration should be asked on Super User or Server Fault.
I wish to edit the git sparse-checkout information inplace using the nvim editor. I have the following code that almost works.
function Choose () {
begin {
$file = New-TemporaryFile
}
...
I have a step in my Jenkins freestyle job that runs a Groovy script as follows:
import java.nio.charset.StandardCharsets;
def creds = com.cloudbees.plugins.credentials.CredentialsProvider....
I made a script that works some of the time to remove McAfee products. The issue is that there are sometimes 2 tmp folders that get created. Then, there's a chance that it renames and copies the wrong ...
I have created a webhook in Azure Automation. I am looking to pass the body when the webhook is called to a logic app. Please see the powershell code designed of runbook.
param
(
[Parameter(...
Can someone check to see if I did this PowerShell problem correct? Also, if you answer it could please explain what I did wrong. That will help me to continue to learn. Thanks!
Problem 3.) ...
I have the following function that gets a list of folder names and displays the results in
a tabular fashion. Once that is done, I want to iterate through that list to do different
things depending on ...
I use PowerShell to check, if specific apps are installed on the users PC:
$Application_MicrosoftEdge = get-package "Microsoft Edge" | % { $_.metadata['installlocation'] }
$...
I am just starting to use Powershell )
I need to compare the file name with a list of file names to exclude some files from further transfer .
This script I wrote :
$E_list= @("**a8e4022a-41c4-...
I try to setup and deploy Azure Function by using PowerShell script based on this topic: Setup Azure Function from PowerShell
My script looks like this:
#=============Defining All Variables=========
$...
I want to check via PowerShell, if a specific product (like "Office" or "Visual Studio") is installed on the target computer, but I can not use any 3rd party PowerShell modules (...
I want to create a VM without nsg. In the New-AzVm cmdlet, I specify $null in the PublicIP parameter - and it works (i.e. it does not create a Public IP). But this does not work with nsg. Here is my ...
I've been trying for a while and still haven't got the solution
Can anyone help me with a Powershell script to go over all the folders inside a path and copy all the subfolders with specific name
for ...
I want to sort a lot files in a new folder location with subfolders. For example files in C:\source should be copied to \server\destination by creating subfolders according the file creation date like ...
I got the below PS script Idea online to create a VM Snapshot report and email it to myself every morning, once I run the script it will get the below error message, can someone help me with that? ...
I want to check if artisan file exist in current directory to set an alias .
take a look what i tried but without any results.
if ( (Test-Path -Path $pwd -Include artisan) -eq $true) {
Function ...
The following code in powershell creates a file with key/value pairs.
$result = @()
Get-EventLog -LogName Security -After ((Get-Date).AddDays(-5)) -InstanceId 4624 |
ForEach-Object {
if ($_....
I am looking for a python script that searchs for a (specific word) in the entire Web page. So after I look around youtube I found youtubers saying "Scrapy is better then bs4".
So I tried ...
I'm attempting to domain join a bunch of workstations (ideally remotely, via Powershell). The problem is I'm forced to use a Smart Card to accomplish this. The problem is that it appears that the ...
I can't login to Windows OpenSSH is my default shell is not powershell. If it is, then
reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
makes ...
I am trying to automate the process of rename the csv header names.
I used the following script, but the script is taking very long time to complete the rename process especially when the file size is ...
I'm stumped.
I have a folder called c:/data/ToDelete. It used to contain files as well as a single subfolder called ..., which contained the same files as well as single subfolder named ... and this ...
I try to process Peppol xml invoices. Sometimes the same node has attributes and sometimes does not. How can I get the text of a node regardless of it having attributes?
$xml=[xml]@"
<Invoice&...
I am trying to build a custom sublime-build that executes c++ programs in powershell.
I want powershell to exit itself on pressing enter or any other key.
How can this be done ?
This is my sublime-...
I have run
wsl --install in windows powershell then I am getting this error. On first time when I run this code it installed and when I restart it started installing Ubuntu but I wait almost more than ...
Trying to get data from crystal disk text file, in order to sort through the data i need to find out how many disks there are, when doing this in regex101 it gets the data fine but when i move this ...
I'm struggling on how to pass a base64 encode inside my API function. It works if I pass manual strings. But I want to dynamic strings.
Here is my code:
$base64string = [Convert]::ToBase64String([IO....
I am trying to execute a PowerShell script with C# with the System.Management.Automation.Powershell object in a kiosk environment, but I am always getting an exception and I have found nothing about ...
I'm building a script that will create an html report containing a table with multiple values in each Column Row (e.g. given cell may have 1 or more values). I'm building my output variable like this ...
We are running our PowerShell Script in Remote Windows Server 2019. We use Connect-AzureAD and Connect-IPPSsesion. The script took about 3 hours to complete the whole process. It was working fine a ...
I need some help with a problem.
Problem: Using a for loop, compute the average of the first 20 odd numbers. Print only the average.
I have figured out how to count the first 20 odd numbers in the for ...
Im trying to get process id from my Get-Eventlog. I can not parse the process id from the message. How ı can get it from there ? I tried With Select string -Pattern but it did not worked. My ...
I use Powershell (version 5.1) to write a simple GUI frontend, and use the "start-process" cmdlet to start the backend program.
However, when passing the parameter with "-ArgumentList&...
Is it possible to highlight words in the terminal as VS Code does? I want to be able to quickly be able to "ctrl+shift+left arrow" and select a word or multiple words and change them quickly ...
I have a PS script written to apply some basic configuration to a device over a COM connection. After some user input is recorded, it is used to format a minified java string to send to the device ...
I have a csv file with a timestamp column that has a custom number formatting in this format mm:ss.0.
I am trying to change that custom number formatting to h:mm:ss AM/PM, preferably during the Import-...
My VS Code keeps shutting down the terminal. (30 s up to 5 min after I open it.) I've tried:
Reinstalling VS Code with deleting the folders %APPDATA%\Code, %USERPROFILE%\.vscode
Using different ...
I am receiving the following error:
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Resource group 'GFPS-P-EUW-RG-...
I'm trying to run a simple icacls to a directory on my computer and I'm facing this error:
PS C:\Users\gguer\Documents> icacls.exe '.\My Digital Editions\'
.\My Digital Editions": The ...
node command freezes Powershell, but works fine in Command Prompt as shown in the screenshot below:
I'm new to node.js and today I've installed node-v16.16.0-x64.msi from
https://nodejs.org/en/
and ...
I have an array with psocustomobjet like this :
$Data=@()
$Data += [PSCustomObject]@{
'RawMessage' = '123'
'MessageType' = 'String'
'Export' = ''}
$Data += [PSCustomObject]@{
'RawMessage' = '456'
'...
I am working on a web application using Angular in Vs code.
I ran into some errors while I am fixing them in the process my vscode is bricked after a couple of minutes it return to its normal state ...
i would like to know how to find UPN that constain digit with -filter?
Get-ADUser -filter {(UserPrincipalName -contains "I dont know what i should add here @contoso.com")} -properties ...
I'm trying to do a history load of data from a ReST api call using powershell. If I were to call the ReST endpoint with no parameters I either run into timeout or out of memory exceptions.
$Header = @{...
When I run the runbook it appears the following message:
Exception of type 'System.Exception' was thrown.
The subscription name XXXX doesn't exist.
Parameter name: name
It's just a simple script to ...
Can someone explain what this error code means ?
Below command is executing BY CODE -
djoin.exe /provision /reuse /domain userDomain /dcname targetDC /machine machineName /savefile c:\rabins\...
I want to keep the first comment section lines of a file and overwrite everything else. Currently this section is 27 lines long.
Each line begins with a # (think of it as a giant comment section).
...
I've this PowerShell Script that get the folder name, Folder path and last modified from either SharePoint Online or OneDrive account but I'm just wondering how can I also get the the file name inside ...
I am trying to write a PowerShell script to link my GPOs to several OUs on multiple domains. The issue I am having is with the New-GPLink cmdlet. When I run the command I get different errors. I can ...
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.