Windows PowerShell is a command line shell and scripting language for Windows that supersedes the CMD.exe shell and batch language. PowerShell is also an automation engine for Windows that provides functionality similar to Windows Script Host and VBScript.

learn more… | top users | synonyms

0
votes
1answer
14 views

Get Notified of Errors in Windows Event Log

I wrote a powershell script to make a database dump that I plan on having run nightly with Windows Task Scheduler. It outputs to a log file so I can make sure everything is working, but I want to be ...
1
vote
1answer
20 views

Copy Command with “%” in path name

I am trying to write a bat file to copy some files into a new directory (which exists). Here is my command: copy ".\050-9800-JJJ-DSC-BAW-MEE-00019-01*.pdf" "T:\201201.00 TCO - Tengiz, ...
0
votes
3answers
22 views

Powershell parse object / string

Learning powershell, trying to find out how to parse the first value from this resultset: IPAddresses ----------- {10.60.50.40, fe80::5ddf:a8f4:e29c:b66} Normally I would just look it up, however, ...
4
votes
1answer
160 views

Powershell: A variable within a variable; Variableception

So the easiest way to explain my problem is for me to show you this simplified version of what I'm trying to do: PS C:\> $a = 'hello' PS C:\> $a hello PS C:\> $b = '$a world!' PS C:\> $b ...
18
votes
5answers
14k views

Setting $HOME in PowerShell

How do I change my default home directory to "C:\Users\khornsby" for every time I open powershell? I am running Windows 7. Below is info about the state of my environment. Windows PowerShell ...
0
votes
1answer
28 views

Generate an error log from Powershell

I created a script to assist in mass editing permissions inside an extensive folder structure, based off a list inside a CSV file. The script works as expected, but for several of the folders, I know ...
0
votes
2answers
19 views

“Migration Assistant” for windows?

I'd like to migrate system settings and installation installed software all personal data users from an old windows 8.1 box to a new one. Basically replicate the awesome Mac OS migration ...
3
votes
1answer
36 views

Administrator denied access to folder, impossible to see/change owner

I have a folder which was generated by MSBuild, app.publish. Often, my build script fails to delete it, complaining that it does not have the necessary permissions. Today I tested this outside of the ...
-2
votes
0answers
17 views

Use powershell/7za.exe to extract multiple zip files [on hold]

The following code ls *.zip | % { c:\bin\7za.exe e $_ -o..\..\unzipped } got the following error messages. Error: Incorrect command line Error: Incorrect command line Error: Incorrect command ...
0
votes
2answers
5k views

How to reset TCP/IP on Windows 8.1?

The following netsh command is not working on Windows 8.1. netsh int ipv4 reset It give “Access Denied” error and it is a VERY known issue, many people complaining about it all ove online forums. ...
108
votes
7answers
85k views

Native alternative to wget in Windows PowerShell?

I know I can download and install the aformentioned library (wget for Windows), but my question is this: In Windows PowerShell, is there a native alternative to wget? I need wget simply to retrieve ...
1
vote
0answers
32 views

Properly extracting from an array

I have a CSV with one column, numbers formatted as 111-0000, that I'm reading in to process one at a time. I'm trying to import the column of information from the CSV, but I'm having trouble figuring ...
0
votes
0answers
14 views

Set font in the clipboard by powershell

My first question here :) I searched a lot and could not find the answer to my problem. I know how to pipe my output to the clipboard. What I want to achieve is to set the contents of the clipboard ...
1
vote
1answer
40 views

Making Batch to run Windows PowerShell, then have it run some text

I am newer to making batch files. I am trying to run a command that will open windows PowerShell in a specific directory, and then once there to run a command. So far I have the following. ...
0
votes
1answer
53 views

WmiEvent for any usb device

I am following this answer, which contains Register-WmiEvent -Class win32_VolumeChangeEvent -SourceIdentifier volumeChange and $newEvent = Wait-Event -SourceIdentifier volumeChange This works ...
0
votes
1answer
30 views

PowerShell Excel search replace issue with loop

What I'm doing here is to search excel sheet for a value, if value matches it will be replaced by first value in a given text file: example: search for value text find the first instance replace ...
0
votes
1answer
4k views

Call PowerShell script from Excel macro

I'm trying to call a PowerShell script from a macro in Excel. I have seen a number of examples along the lines of: retval = Shell("powershell ""C:\MyTest.ps1""", 1) When I try to use this, ...
1
vote
2answers
3k views

Download entire directory from a website using Powershell

I have been using the following command to pull back files from a web server and store them on my local machine: $client = New-Object System.Net.WebClient ...
0
votes
1answer
19 views

Using -replace on pipes in powershell

I want to test out a replace before I use it, so I'm trying to write a quick online command to see what the output is. However, I'm not sure what the syntax is. What I want to do is something like ...
0
votes
3answers
4k views

How to run “winrm quickconfig” on all LAN computers remotely

I want to start doing my remote LAN work using powershell, but it seems I need to run winrm quickconfig on all LAN computers before I can remotely connect to them. How can I run that command on all ...
-1
votes
1answer
15 views

Modified and creation time for file in powershell

I would like to get the modified and creation time for file in powershell. This commandd: forfiles /m *.* /c "cmd /c echo @file @ftime" gives the modified time. What is the attribute name for for ...
0
votes
0answers
14 views

Backrefence syntax in powershell's sed

How do I back reference a capture group in powershell's sed? I can't seem to find the syntax for it. IE I expect echo "hello" | sed "s|(h)ello|world\1|" to output worldh, but instead I get the ...
0
votes
1answer
33 views

PowerShell script to decrypt file

Can some one help me with this command to decrypt files using powershell? echo YOURpassPHRASE | gpg --keyring "C:\directory\filepath" --secret-keyring "C:\directory\filepath" --batch --yes ...
5
votes
4answers
7k views

Get the current UNC path from a local path in powershell

Assuming I have a mapped drive M:\ to \\SomeServer\SomeShare and in powershell I'm in the folder M:\SomeFolder how do I convert that to a UNC path, i.e. \\SomeServer\SomeShare\SomeFolder.
5
votes
2answers
2k views

Running Script on Shutdown using Windows 8

Is there any way to execute a Batch- or PowerShell-Script on shutdown using Windows 8 without disabling FastBoot? I know you can add a script using "gpedit.msc", but I found that Windows 8 won't ...
37
votes
2answers
36k views

How do I run multiple commands on one line in Powershell?

In cmd prompt, you can run two commands on one line like so: ipconfig /release & ipconfig /renew When I run this command in PowerShell, I get: Ampersand not allowed. The & operator is ...
0
votes
1answer
18 views

Simple addition in CSV using powershell 2.0

Given a csv-file of the following form: example.csv 1,2,3,4 5,6,7,8 ... What is a powershell script I can use to add the first two elements together and update the same input file, like this: ...
0
votes
0answers
28 views

Schedule task to run monthly with powershell

I'm trying to create a scheduled task with powershell, the task is supposed to run the 10th every month, but I can't figure out how to use New-ScheduledTaskTrigger with a monthly interval. $t4Name = ...
1
vote
0answers
28 views

Powershell tee command locks file

Is it possible to run powershell tee command so that it doesn't lock the file, allowing to view it?
38
votes
10answers
25k views

Equivalent of Linux `touch` to create an empty file with PowerShell?

In PowerShell is there an equivalent of touch? For instance in Linux I can create a new empty file by invoking: touch filename On Windows this is pretty awkward -- usually I just open a new ...
0
votes
0answers
22 views

How to append output from sqlcmd argument to txt file?

I am 100% new to batch files, so bear with me. sqlcmd -U %username% -P %pw% -S ServerName -d TableName -i "%%G" >> output.txt This doesn't work. It works fine without the >>. The error ...
0
votes
0answers
12 views

posh-git not reading my profile

I'm using posh-git (part of Github for Windows). I want to set a custom prompt as in this question. However, posh-git is not reading my profile file. I have tried: Running PowerShell as ...
1
vote
1answer
5k views

How to fix this WinRM error? (Set-WSManQuickConfig error)

On Windows XP Pro SP3, when I run Set-WSManQuickConfig (after agreeing to the new settings), I get this error: Set-WSManQuickConfig : <f:WSManFault ...
1
vote
2answers
33 views

Bulk Folder Renaming Powershell Script

The script below is used for Bulk Folder Renaming. However I wanted to make this as a Generic Script so users can give input and use it accordingly. This script has 3 inputs a) Enter the Source ...
0
votes
1answer
31 views

Unable to delete .swp file

I'm using Vim on Windows 7 Enterprise. Vim sometimes creates an .swp file. After closing Vim, this file sticks around. I would like to delete it. However, I receive the following error: ri : Cannot ...
1
vote
1answer
35 views

Robocopy Log File Meaning of New File, New Dir

I've been learning and using robocopy a lot for the last few weeks. One thing I have not been able to find is good documentation on the terms used in the default log file. There is no header row in ...
1
vote
1answer
33 views

Can robocopy show the console and create a log file?

I'm working with robocopy for the first time and have got most of it figured out and working well except logging. I have experimented a bunch and if I run my job like this: robocopy /xc /xn /xo ...
-1
votes
0answers
15 views

Powershell x86 on Windows 8, Sony Tab20

trying to kill or stop-process a few PIDs, but powershell won't accept any commands like "kill" or "Stop-Process". What do I use to stop the process?
3
votes
1answer
4k views

What is the Start Screen Control in Windows 8.1 Enterprise

I have read different things on the new Windows 8.1 Enterprise RTM. One of the feature is the Start Screen Control. Start Screen Control: This feature allows you to control the look of the Start ...
0
votes
0answers
8 views

Copy from SFTP to local host using Username/ privatekey.ppk using powershell

would you please help me , i need script that copy files from FTP server to local host using only Username and .ppk as a private key , i don't have password. is it possible to do that. Please ...
0
votes
1answer
25 views

passing value from powershell script to cmd script

I want to pass value “200001” from the PowerShell to cmd script “1%” The cmd script used by multiple powershell scripts, and each PowerShell script has its own value. PS script: function ...
1
vote
1answer
7k views

Calling PowerShell functions in another scripts

I have a script with a number of functions (not just functions but also other code). I would like to create another script that uses one of the functions in the main script. Here is a sample of what ...
0
votes
2answers
46 views

Detect powershell function input is redirected

I have a subprocess that I want to call from powershell that might be interactive or I might pipe data straight into it. For example: # This is interactive: & c:\python27\python.exe # This takes ...
1
vote
4answers
173 views

Moving a folder across the network

I need to move (not copy then delete, for the sake of file verification) a folder from a network folder to another network folder using Powershell. I have tried Move-Item (where test1 is a folder): ...
0
votes
1answer
2k views

Powershell File Rename Date/Time

I have used a script from a previous post and modified it slightly: Get-ChildItem "c:\test\*.txt" | ForEach-Object { Rename-Item $_.FullName "$BackupFolder$($_.BaseName -replace " ", "_" ...
0
votes
1answer
21 views

Why does $_.Name include full path when within quotes in Powershell?

When I run this in powershell it outputs the name of my files (in this case just one), without full path: PS C:\dev\temp> gci test.* | % { $_.Name } test.txt When I put the name in quotes for ...
22
votes
4answers
7k views

Powershell equivalent to unix `which` command?

Does powershell have an equivalent to the which command found in most (if not all) unix shells? There are a number of times I'd like to know the location of something I'm running from the command ...
0
votes
0answers
48 views

schtasks.exe - Start At Login, Run Every Minute

I'm having trouble getting schtasks.exe to create a Sheduled task that will: Start at logon Repeat at minute intervals I've tried the following: schtasks /Create /SC MINUTE /MO 1 /TR ...
0
votes
1answer
30 views

PSModule provider is missing

I recently installed Windows 10 on my laptop. Problem is that I cannot install apps from OneGet because I cannot install Chocolatey source because PSModule provider is missing. Screenshot: Click for ...
0
votes
0answers
30 views

Powershell not recognizing Commands

I'm a beginner in PowerShell, I've been working with it for a little while, but suddenly it started not recognizing some commands, for example , typing the Command Set-Location, generates this error : ...