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

1
vote
1answer
2k views

Prefix files with the current directory name using Powershell

I have folders with images (*.png and *.jpg) >C:\Directory\Folder1 01.png 02.png 03.jpg 04.jpg 05.png And I want to rename all the files like this using powershell: >C:\Directory\Folder1 ...
1
vote
3answers
151 views

Variable Assignment for arguments with a for loop [closed]

Alright, so, I've searched quite a bit on how to do this but I've given up as I simply couldn't find anything. So, I have a code (below); it's main purpose is to get 9 arguments and assign them as a ...
32
votes
2answers
33k 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
2answers
361 views

How to prevent carriage return being copied to clipboard in Powershell?

I have a powershell script that is hashing the MAC address, then posting it into a file and a clipboard. $hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($MAC))) $hash | clip ...
-1
votes
1answer
131 views

Can't load a .bash_profile on windows powershell

I'm looking to load a .bash_profile with some aliases and functions on launch but, I haven't been able to find a way to load the .bash_profile. I'm not even sure if it is possible.
0
votes
1answer
69 views

Powershell and SQL Script Execution in selected schemas

Any one please help me on this one also..I have got many schemas under one database. And in that database I have some SQL Scripts to be executed. My issue is that I should be able to execute those sql ...
2
votes
2answers
24k views

How to use the cd command in Windows Powershell to change the drive that I am working [closed]

I read this answer but it doesn't work for Windows PowerShell. How to change the drive? EDIT: Please ignore this question. I was trying to change the drive from C: to D:. The reason it wasn't working ...
0
votes
1answer
162 views

Microsoft.SqlServer.SMO.dll issue in powershell

I dont have a sql server installed in my server. I am designing a powershell script that can execute sql scripts remotely in a db. I have powershellv1.0 in my server and dont have ...
3
votes
3answers
2k views

Run powershell through winexe/psexec

I'm trying to connect to a Windows 2012 server from Ubuntu. winexe --user <USER> --password <SERVER> //SERVER cmd.exe works just fine. However, winexe --user <USER> --password ...
2
votes
1answer
441 views

Version 1 powershell, get-childitem to look only in a listed directory, not all subfolders

I have v1 of powershell on my servers. It would be easy if I had a newer version of PowerShell but that is not an option for me at this point. I have a script that looks to see if a file in a ...
2
votes
1answer
3k views

Running IIS command on remote server via Powershell

I am trying to check if an IIS application pool exists on a remote server using a PowerShell script. The command I am running is: test-path "IIS:\AppPools\DefaultAppPool" If I run this script ...
0
votes
1answer
194 views

PS to list all schemas

This may be simple enough.But since I am new to powershell handling sql script,I am here with a question. After getting connected to a database how can we retrieve all the schema's listed in that ...
3
votes
1answer
17k views

create a log file using powershell

Can someone please help me on how we can create a log file using powershell? I am using this code for log file creation.. # Log file time stamp: $LogTime = Get-Date -Format "MM-dd-yyyy_hh-mm-ss" # ...
3
votes
1answer
4k views

Is it in any way possible to uninstall PowerShell from Vista?

Is it in any way possible to uninstall PowerShell from Windows Vista? There is no Uninstall option under Start/All Programs. It's start menu group is actually located under Accessories which is hard ...
1
vote
2answers
275 views

Opening PowerShell at the current working directory from the registry

This question is prompted by a problem I faced while writing this answer. I am invoking PowerShell like this from the registry: C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoExit ...
5
votes
2answers
3k views

how to set PowerShell as default instead of cmd.exe

I'm trying to get PS to open up instead of cmd.exe when I do a Shift+left-click and select open command window here I changed the %ComSpec% system variable and even added on in my user variable ...
1
vote
2answers
790 views

Batch create folders?

I'm looking for a way to batch create a folder followed by sub-folders. I'm looking at something like c:\users\user\desktop\sample\1 c:\users\user\desktop\sample\2 etc. Any ideas? I'd prefer ...
1
vote
1answer
520 views

PowerShell Expression interpreter on variables

In response to this question, the original requester wanted to know In PowerShell, is there a way, after typing a long or complicated command, to commit that command into the history buffer, but ...
-1
votes
1answer
186 views

Replacing a string in all config files across machines with a script [duplicate]

I have the below task and I am wondering what would be the best and quick way to do this. I am thinking scripting rather than a C# app but struggling with scripting in DOS. I wanted to use powershell ...
0
votes
0answers
145 views

Setting up microsoft intune, need to lock down computer

So, I have an initiative to set up Microsoft Intune on a number (~450) remote computers. Those computers are currently running deep freeze to reduce the damage that people can do to them by ...
4
votes
3answers
160 views

In Powershell, is there a way to save a typed command into history without executing it for later execution?

In Powershell, is there a way, after typing a long or complicated command, to commit that command into the history buffer, but not execute it? For example, you start typing a git commit, within ...
-1
votes
1answer
1k views

Multiple counts from Powershell Get-ChildItem? [closed]

How would I use powershell to count the number of files and the number of folders under a folder, emulating the Windows "properties" of that folder? (get-childitem -recurse).count returns the total ...
2
votes
2answers
2k views

How do I grant a user permission to add local users in Windows 7?

How do I grant a local user account the permission to add other local users in Windows 7 Professional? The important point is, that the local user who should be able to create new accounts must not ...
1
vote
1answer
48 views

Given a file, get the location in a separate (identically structured) directory?

Being completely green to Windows shell and cmd scripting, I'm banging my head against this particular problem but coming up with nothing. What I'm aiming to do is add a context menu item to right ...
1
vote
1answer
4k views

Powershell script to fully automate joining the domain

I'm trying to create a script to completely automate joining the domain to use during a wds image deployment. I don't want to use the WAIK option because the password is stored in plain text in the ...
5
votes
2answers
5k views

Remote powershell permissions restricted to machine

I am unable to execute powershell scripts on a remote server, but only on my current machine - please help. Running the following script to give a list of a temp directory on the remote server works ...
3
votes
2answers
2k views

How to open an Outlook contact using a Windows command-line script?

I tend to store a lot of information in the Notes fields of Outlook contacts. Accessing this detailed info for a specific contact in Outlook 2013 requires many steps on the Windows desktop: opening ...
0
votes
2answers
151 views

How to remap shortcut in Powershell

I want to remap the shortcut in powershell, for example, I'd like to use Ctrl + a to make cursor at beginning of line, Ctrl + e to make cursor at the end of line, etc. I searched the method in Google ...
-1
votes
1answer
1k views

PowerShell, SSH, Keyboard Interactive and Frustration [closed]

Hello Stack Overflowers! My goal is to utilize Powershell and SSH to connect to a Unix system (specifically an Avaya PBX switch). Once logged in, to change the terminal type to ossi (avaya specific) ...
3
votes
2answers
97 views

How can I pass two commands with all their switches in Windows command prompt or powershell?

I want to pass a netstat -t -b 90 command and tell the prompt to simultaneously or successively perform this command to launch network monitor start netmon /autostart.
1
vote
1answer
590 views

Batch script for archiving

I need to set up an archiving task on Windows 7 using Windows command line and WinRAR (or some other similar program). I want to create a script that does this, but I have no prior experience. I want ...
2
votes
2answers
221 views

How can I identify files in my Windows file system where the modified date is X more recent than the created date?

I'm hoping this can be handled with some PowerShell tricks. I have a directory on my work machine (Windows XP) containing tons of PDFs, some of which I've annotated and resaved. I'd like to be able ...
0
votes
1answer
8k views

How to repair powershell installation on windows 7

When I try to run powershell.exe from C:\Windows\System32\WindowsPowerShell\v1.0 I get the error: 'The volume for a file has been externally altered so that the opened file is no longer valid.' I ...
9
votes
2answers
175 views

How to customize the default CursorSize in Powershell

I set he default CursorSize in $PROFILE file like: [Console]::CursorSize = 10 or $HOST.UI.RawUI.CursorSize = 10 But the cursorSize will reset after using another console in powershell, for ...
5
votes
1answer
4k views

Task Scheduler - how to run powershell script with multiple parameters?

I am using powershell.exe as the Program and "-Command "& C:\Windows\logon.ps1; exit $LASTEXITCODE"; ExecutionPolicy RemoteSigned" as the Parameter, but it doesn't seems to be working. Some ...
4
votes
3answers
8k views

How to disconnect a network drive using powershell

I would like to disconnect a network drive (Y:) with powershell. That drive letter is assigned / mapped to a network location. Is there a simple way to do that? I believe "net use XXX /delete" would ...
1
vote
1answer
1k views

PowerShell touch all files newer than

I have found the following question on ServerFault: Windows recursive touch command Which partially answers my question with this answer: Windows recursive touch command However, I would like to ...
1
vote
2answers
336 views

How to rename some files according to their timestamp

suppose I have 10 files generated by the system every day under D:\Temp. The names are RANDOMLY when generated. Assume I need to rename the oldest one to be 'aaa', the second oldest one to be ...
3
votes
1answer
7k views

Office 2013 Click to Run - Primary Interop Assemblies

Given that the Office 2013 click-to-run installer allows no customisation of the installation, whatsoever, how can I install, or where can I find an installer for the Primary Interop Assemblies/.NET ...
6
votes
1answer
2k views

Change directory to previous directory in Powershell

I am a Linux guy, but am trying to be open-minded and learn some Powershell. I miss the ability to cd - back to a previous directory, like in *nix shells. Is there a similar command in ...
2
votes
2answers
983 views

How can I use powershell to list all files I uploaded to server?

At work there's a network and everyone has a username and password that they use to log in. How can I search for my files on this network? I could list all the files like this: cd ...
1
vote
3answers
952 views

powershell create zip from log files

How can I move log files to zip archives with System.IO.Compression.FileSystem in PowerShell? I have more folders with log files per application: app1logfolder |-app1_20130507.log ...
3
votes
2answers
4k views

How to use UNC path correctly to share a folder on remote computer?

I would like to know if somebody knows the correct syntax for giving a folder a share on remote network machine's folder. Please write a syntax you know for sure that it's working. This operation ...
1
vote
1answer
483 views

Powershell script to update XML file content

Please help me create a Powershell script that will go through an XML file and update content. In the example below, I want to use the script to pull out and change the file path in the ...
5
votes
1answer
97 views

Program leaks Black and White onto PowerShell console

Some programs, such as Node Package Manager (npm) and some tasks for grunt change the color of my PowerShell console and leave it that way. Here's a picture: Anyone know why this is happening? How ...
0
votes
1answer
2k views

Set Physical Path Credentials in IIS7 Using Powershell

I have a number of applications under a Default Web Site in IIS7. A number of the applications have to have their Physical Path Credentials set to a specific user rather than using application user. ...
3
votes
1answer
527 views

Detect mounting of a virtual (TrueCrypt) volume in windows PowerShell script

I am using the following powershell script to detect when a particular volume is mounted so I can run a script that will move files from my machine to the device (I don't know much about powershell ...
1
vote
1answer
279 views

PowerShell icon missing from taskbar

Windows Server 2008 R2 SP1 I installed PowerShell 3 by installing Window Management Framework 3.0 (Windows6.1-KB2506143-x64.msu) Somehow the PowerShell icon has gone missing from the taskbar. ...
1
vote
2answers
1k views

How can I write a script to count files modified within a particular month?

I use a PowerShell command to count ZIP files modified within the past 30-ish days, that goes something like this: (gci "\\servername\sharename\foldername\subfoldername\*.zip" | where ...
2
votes
1answer
464 views

How to enable CredSSP

I am trying to use the -Authentication CredSSP switch when entering with PowerShell (2.0) in order to remotely launch a Script that can write to files or set up new PSDrives. I get an error when I ...