Questions tagged [powershell]

PowerShell is a command line and scripting utility for Windows. Use this tag for questions about writing and executing PowerShell scripts ONLY. Programming questions specific to the cross-platform version PowerShell Core (Windows, macOS, Linux) should be tagged [powershell-core]. Questions about ...

0
votes
0answers
1 view

Passing subset of objects down pipeline, based on count of properties?

I need to script up some things in PowerCLI (VMWare's bolt on to Powershell). Basically we have a server cluster with three hosts. Each host has multiple virtual switches. Each virtual switch has ...
0
votes
0answers
10 views

“Use for App service” parameter in Add-AzureRmApplicationGatewayBackendHttpSettings cmdlet

In the Azure Application Gateway UI, when creating a HTTP Setting, there's a tickbox called "Use for App service": I'm trying to replicate this HTTP Setting in PowerShell using the following command: ...
-2
votes
0answers
9 views

Deploy SQL scripts to multiple environment using CmdletBinding and Param

I have two environment DEV and PRD where I need to deploy SQL Scripts, The SQL script are in a folder having 4 subfolders, Tables, Views, Stored Procedure, Others. I need to create a power shell ...
0
votes
1answer
11 views

SQL Azure powershell commands not recognized anymore. Deprecated?

Already discussed at: Get-AzureSqlDatabaseServer : The term 'Get-AzureSqlDatabaseServer' is not recognized as the name of a cmdlet I just need to be sure if this behavior is due to the whole Azure ...
1
vote
1answer
13 views

Running Invoke-WebRequest as System account

I want to run Invoke-WebRequest as System in a scheduled task. The cmdlet fails with the following error: Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer ...
0
votes
1answer
15 views

In powershell with psreadline -EditMode VI how to ensure the cursor starts at the end of the line when going through history

I'm using the powershell VI mode via Set-PSReadlineOption -EditMode vi It is awsome to be able to edit the line using VI commands however there is one thing that is annoying. When using the up and ...
0
votes
0answers
22 views

Strawberry Perl — where are encoding conversions done by default?

Basically, I wrote a Perl script that creates an encoded command for Powershell and tries to run it. I had to explicitly convert the command string to utf-16 before base64-encoding it. I'm wondering ...
0
votes
2answers
26 views

Is there any Primary Key (or) Unique Key is present in Active Directory?

I am running the below command from PowerShell: Get-ADUser -Server ad.com -Filter '*' -Properties '*' Export-Csv 'C:\Users\myFolder\file.csv' -NoTypeInformation -Delimiter '|' Just trying to ...
1
vote
1answer
23 views

Pass multiple values through pipeline

I want to be able to pass multiple values through the pipeline for a module I am building. The module is built around a specific SQL Database Schema so i designed this function to return all databases ...
1
vote
4answers
38 views

Split string in PowerShell by pattern

I have a fairly long string in PowerShell that I need to split. Each section begins with a date in format mm/dd/yyyy hh:mm:ss AM. Essentially what I am trying to do is get the most recent message in ...
0
votes
1answer
25 views

Compare within same result set of Compare-Object

I have a CSV file that contains the Name, Size, and Hash (filename, size in bytes, and MD5 hash) for every file on one of my storage appliances. Once this data is moved, I will generate the hash for ...
1
vote
2answers
43 views

How to print UTF-8 (or unicode) characters in Go (golang) on Windows

Let's have a look at this: ✓ Hello, 世界 As you can see there is a unicode checkmark and chinese/japanese characters. In go, If I use MSYS or linux environment i can easily print those characters. ...
0
votes
1answer
15 views

How can you get valid JSON for Azure Data Factory V2 Datasets/Pipelines using PowerShell?

I have some pipelines in Azure Data Factory V2 that I need to update. Specifically I need to update the schema of the datasets. I initially created them using the user interface. Since the number of ...
2
votes
5answers
54 views

Find strings between quotes, but before colon?

I've tested at all sorts of examples and non of them seem to work for me. Given a string like this: "FOO":{"BAR":"0x507A","FIND":"DONTFINDME","ME":["0x3214"]} Is there a RegEx I can use to get ...
-1
votes
0answers
18 views

Trying to walk multiple oids but nothing happens

I have been trying to use PowerShell's Invoke-SnmpWalk to set up a script to monitor the health of the drives of a Synology device. But when I try to use a variable at the end of the OID to go through ...
1
vote
1answer
31 views

Listing files from azure file storage that are 10 days old using shell script

$context=New-AzureStorageContext <AccountName> <AccountKey> $isOldDate = [DateTime]::UtcNow.AddDays(-10) Get-AzureStorageFile -Context $context | Where-Object { $_.LastModified....
0
votes
1answer
16 views

Raw data in Custom Comments with functions in power-shell when piping to a Format-Table

I'm trying create a cheat sheet for a power-shell module that I'm writing. I am using the custom help message that you can add into a function in a powershell module. Then Calling the Get-Help on each ...
0
votes
1answer
15 views

Python script to Invoke *.ps1 in windows operating system

I am running a Python script in my laptop(windows 64 bit) but I want to invoke a windows powershell script to perform some task. This *.ps1 file should be invoked whenever I run this Python script on ...
0
votes
1answer
17 views

Trying to get a list of all active employees in a distribution group in exchange via powershell

There is an all employees distribution group already in place, I need to get a list only of all "Active Employees" from this group. How do I go about using Exchange Management Shell?
-2
votes
0answers
31 views

Script with a few actions needed (file moving, renaming, creating logs, monitoring folder etc..)

I apologize for the long-winded question/request: We have an SFTP server Our customer will upload a file every day at 12PM EST With WinSCP we run a PowerShell Script to Update Local Directory The ...
0
votes
2answers
26 views

How can I transfer file via RDP-connection over PowerShell or CMD?

I need transfer file via RDP-connection over command line. How can I do that?
0
votes
1answer
22 views

Error assigning variable in scheduled task action

I have a .xml file containing a username and encrypted password (the accessid and key for an API). Using the following line, I retrieve the credential: $Credential = Import-CliXml -Path "${env:\...
1
vote
2answers
38 views

Powershell Delete first word only of a line

My Text File has below content: author : abc Revision : 123 Date : 9/4/2018 11.15.50 AM Path : testabc Message : Req ID:abcd1234 Rev:1.0.0 Status:...
1
vote
2answers
24 views

powershell Export to csv from a ForEach

Pardon me but I an not strong in PowerShell (version 5) as I want to be. I have played with a lof of solutions found on this site but haven't stumbled on a solution for this code. Basically this code ...
0
votes
1answer
26 views

Error handling Azure Powershell - specific errors and responses

Trying to get something set up in powershell that will eventually go into Azure automation. Specifically, trying to add a new DNS record, using the following command: $Hostname ="testhostname" $...
0
votes
1answer
25 views

PowerShell executing exe with arguments

I wrote a PowerShell script to execute exe with arguments which has spaces but it keeps failing, not reading the full path. $now = Get-Date -format "MM_dd_yyyy" $onepath ="C:\Program Files (x86)\...
8
votes
0answers
38 views

Hosting PowerShell core remoting in dot net core app? Has anyone made it work yet?

I've been trying for a month now to host powershell core remoting scripts, that use SSH protocol for remoting, in a dot net core application and so far nothing worked. One of my main issues is that ...
-2
votes
1answer
40 views

How can I know if the Windows' PC has the latest updates from Powershell? [on hold]

Someone told me that it is possible to know if the Windows OS is updated or not from a script running in Powershell. I don't know how to do this particular operation, and then also pass the result in ...
0
votes
1answer
18 views

Provisioning state blank when creating Backend Address Pool

I am running the following commands to try and create a new Backend Address Pool in Azure's Application Gateway service. $NewBackendPool = New-AzureRmApplicationGatewayBackendAddressPool -Name "MHA-...
0
votes
0answers
14 views

New-IISSite new site not visible in IIS Manager

I am creating a new site on my Windows 10 box using New-IISSite -Name "mysite.local" -BindingInformation "*:80:mysite.local" -PhysicalPath "c:\inetpub\wwwroot\mysite.local" This works, when I call ...
0
votes
1answer
28 views

Getting connection property name

The following script here has a hardcoded name of a connection (TD_NAME). i would like to make this a variable that fetches the connection name as it is in the server. write-host "Processing job ...
0
votes
1answer
16 views

Calling a powershell script with Gradle

I am new to Gradle, so bear with me.. I am simply trying to call a .ps1 file to execute with gradle. How would I go about setting up a build.gradle file to execute the .ps1 file within the same ...
0
votes
0answers
20 views

Remove user from registry ACL

I'm trying to remove a user from a registry ACL. My code so far: $regPath ="HKLM:\software\wow6432node\myapp" $userToRemove ='builtin\users' $acl = Get-Acl -Path $regPath # Loop over users and ...
0
votes
0answers
27 views

How to wait for dot-sourced script to finish?

I'm writing a PS script to run a Pester test. . .\..\LoadModule.ps1 . .\..\..\SomethingElse\LoadModule.ps1 Import-Module Pester -MinimumVersion 4.0.0 Invoke-Pester -Script .\Test\ However Pester ...
1
vote
1answer
26 views

Different file size between powershell and cmd [duplicate]

I am using a little processconf.js tool to build a configuration.json file from multiple .json files. Here the command I am using : node processconf.js file1.json file2.json > configuration....
0
votes
0answers
26 views

how to change encoding of string variable to UTF8 in powershell

In my PS script I have a string variable which is later used as a body of html email. I need to change encoding of the variable to UTF8 so that the text will be displayed correctly in the email. The ...
2
votes
0answers
31 views

Extract private key from pfx file or certificate store WITHOUT using OpenSSL on Windows

As the title suggests I would like to export my private key without using OpenSSL. If I need a .cer file or .pfx file I can easily export these via MMC or PowerShell pkiclient but I can't find a way ...
0
votes
2answers
33 views

How to set service startup mode to manual or automatic for a variety of servers?

First, I want to stop the services and then turn them on manually $getservicestatus = (Get-Service -DisplayName $servicename -ComputerName $server).status if ($getservicestatus -eq "Running") { ...
-5
votes
1answer
43 views

Shell command to delete all sub folders and files

I need command to delete all sub folders and files from the root folder. Eg: D:\ contains four folders Folder1,Folder2,Folder3,Folder4 All four folders have a test subfolder test contains many ...
0
votes
1answer
34 views

Add filter with Powershell compare_object

I have two .csv files and I need to compare them. The first one is an extract of the Active Directory, the other is an extract of the registry Profile list. When I compare them, I want to only ...
-1
votes
2answers
29 views

Fill a variable in a condition from xml

what I have is a variable called $usercity.city obtained with a Msoluser query to get a user city. What I need to do is to populate a variable called $icthead depending from that value. I mean I have ...
0
votes
1answer
20 views

Auto Generating field variables

I use the following code to generate checkboxes on a powershell GUI- $databases_checkBox_1 = New-Object system.windows.Forms.CheckBox $databases_checkbox_1.Width = 200 $databases_checkBox_1.location =...
-1
votes
0answers
27 views

Corrupt zip file after being transferred via Netcat [on hold]

I tried sending a zip file from windows to linux via netcat. The zip file gets corrupted. I am not sure whether this is a SuperUser or StackOverflow question, as it has some fiddling with powershell ...
-1
votes
0answers
14 views

Folder permission not reflecting

I have created a PowerShell script that will create folder structure on a file server which is located in the same network.The network in purely remote, created on same network of Azure, both file ...
1
vote
0answers
33 views

Powershell Function Return Value is changed

I have a problem with functions in Powershell. I want to give back a int32-Value, but the Value & the Data-Type are always getting changed... I have no idea why. Thats the main part, where the ...
0
votes
0answers
31 views

PowerShell can create a Shortcut without name

Is it intentional that it is possible to create a shortcut without a name? (Via GUI it is not possible) I am not able to set a hotkey at an url shortcut while it is possible via the GUI. Is that a ...
0
votes
1answer
16 views

How to find out and replace a specified string with rules then write to the source file?

I have worked on a batch script with Powershell, it needs to be run with a schedule file and the contents as follows: Server;Services;ContentPath;Status(Ready,Done,Disabled) server1;servicename1;c:\...
-4
votes
1answer
33 views

Missing bracket bug in powershell [on hold]

I have the following script snippet: if (2 -eq 2) { write-host "1" if (2 -eq 2) { write-host "here" if (2 -eq 2) { ...
0
votes
1answer
23 views

Powershell script - gci

I'm trying to divide output into two files with following script: try { gci C:\Windows\System32 -r -Force | % { if (!$_.PsIsContainer) { $_.FullName; $file = $_....
0
votes
0answers
36 views

PowerShell session not running more than 100 processes in remote machine

I have an application on a remote machine which spawns about 300 instances of different executable. It works fine when I double click on it, but when I try to execute the main application from a ...