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, ...

learn more… | top users | synonyms (1)

1
vote
4answers
5k views

How do I run a powershell with a Windows form at logon / startup?

I'm putting together a powershell (running on Windows 7) which performs some configuration tasks post-image. It uses windows forms to get some user input and then should run various tasks depending ...
3
votes
2answers
2k views

Automatically run a powershell script elevated

Is there a way to run a powershell script automatically in Elevated mode? I am trying to automate some post-image tasks without user intervention, but am getting caught with the UAC. Is there a way ...
1
vote
2answers
4k views

“Correct” way to programatically join a Windows 7 machine to the domain

What is the preferred method to programatically join a windows 7 machine to the domain? I want to script this so that when a newly imaged machine is booted up it joins the domain. (I don't want to ...
0
votes
1answer
2k views

Parse wevtutil XML into a database?

I'm by no means an XML expert. Ergo, I'm having trouble importing Windows event XML from wevtutil into an SQL database. Prior to Server 2008, we exported event log data to the database directly ...
1
vote
0answers
834 views

Using Powershell to set user permissions in Reporting Services

Apologies if this appears to be a gimme-teh-codez question, but i'm asking this because i'm a n00b when it comes to Powershell. How do i use Powershell to add a particular domain user or group to a ...
7
votes
5answers
8k views

Query schtasks using Powershell

On a Windows7 machine I am trying I can run a query to view all the scheduled tasks using schtasks.exe This is fine but I would also like to filter the result set using something like schtasks /...
2
votes
1answer
4k views

Remote installing an msi on citrix servers using WMI

OK, I'm a C# programmer that is trying to streamline the deployment of a custom windows form app I inherited and built an installer for with WiX (this app will need to be reinstalled regularly as I'm ...
2
votes
2answers
3k views

Power Shell does not like command

Any ideas what I did wrong here? I copied this script from a tutorial and get this error.... PS C:\Windows\system32> Get-Service | Where-Object ($_.status -eq "running") Where-Object : Cannot ...
2
votes
2answers
939 views

Where do dsrm, dsadd and dsmove come from?

I am writing a script to join a machine to the domain after it has been imaged. (Don't want to do it in Sysprep.) On the machine I am writing the script on (a battered, world weary IT workhorse with ...
2
votes
2answers
1k views

Powershell script to append an extension to a file, input from CSV

All I need is to have an Excel list of file paths and use Powershell to append (not replace) the same extension on to each file. It should be very simple, right? The problem I'm seeing is that if I ...
0
votes
1answer
549 views

Set Outlook stationery via Powershell

I want to set Outlook stationery to a particular template on all the machines on my network using Powershell (through a login script). Can someone point me in the right direction? Thanks, Ben
7
votes
1answer
4k views

How To Disconnect Users Accessing a Windows Shared Folder using PowerShell

The Determine Users Accessing a Shared Folder Using PowerShell question has a good answer. Continuing on from that How do you disconnect the users accessing the share using a powershell script. ...
7
votes
3answers
1k views

Delete a windows group in Active Directory

I am doing a cleanup of some AD groups that are no longer used. One of the AD groups I could not delete because it seems that a member has this group set as the primary group (which I assume someone ...
0
votes
1answer
1k views

JoinDomainOrWorkgroup Method FJoinOptions help

Anyone have experience of using the JoinDomainOrWorkgroup Method of the Win32_ComputerSystem Class? I want to write a powershell script to join a machine to a domain. There may be an existing ...
0
votes
1answer
17k views

Exporting specific fields with powershell's export-csv

I am trying to export a list of some user information from Active Directory 2003 using Powershell. So far, I'm able to display the specific list of properties using something like this: if ( (Get-...
1
vote
3answers
1k views

Can I run AD commands from a standard PowerShell script?

I am putting together a script to run post-sysprep. It should check if the machine is on the network, and if it is then it should query AD to see if a computer account exists with it's service tag (...
4
votes
2answers
160 views

Is it possible to eliminate the console flicker when opening the PowerShell ISE?

I really hate the black console flicker that occurs when opening the PowerShell ISE. Is there a way to keep this from happening?
7
votes
1answer
3k views

PowerShell: How to customize prompt?

I like to define the env variable PROMPT as $p$_$g so prompt starts in a new line. But seems to be not applying to my PowerShell prompt :-( dir function:/ shows that a name "prompt" is already ...
3
votes
2answers
2k views

How do I make wallpaper fit both monitors in dual monitor setup?

I am deploying some custom corporate wallpaper as part of a Windows 7 rollout. Some people will be using dual monitors, and the additional monitors may be either 4:3 or widescreen. I want to use the ...
2
votes
1answer
5k views

Pre-provision MySite user site via script?

We're considering pre-provisioning each user's MySite in SP 2010 - I know MS don't recommend it but it's a Uni installation and we'd like to have the student accounts set up in advance rather than ...
1
vote
3answers
3k views

Powershell Win32_NetworkAdapterConfiguration Not “seeing” PPP Adapter

I am trying to get the IP of a PPP VPN network connection, but Win32_NetworkAdapterConfiguration does not seem to "see" it. If I interrogate all adapters using my script, it will see everything but ...
1
vote
4answers
155 views

Best way to script checking whether a machine is on the corporate network

I am writing a Powershell script to determine if a machine is on the corporate network. The machine may or may not be on the domain, so I want to check at "IP" level. Have written something to check ...
1
vote
4answers
9k views

Specify Credentials to run Powershell Script to Query AD

I want to run a powershell script to query AD from a machine that is NOT on the domain. Basically I want to query to see if there is computer account already on the domain for this machine and create ...
7
votes
3answers
8k views

Launch different Powershell console from a console?

If I'm working within a single powershell console, and say I want to spawn another powershell console window. Is there a way to do this? If you type "powershell" at the prompt - it doesn't launch a ...
3
votes
1answer
2k views

How do I install Windows PowerShell on a Windows Server 2008 R2 Server core installation?

I found pointers to ocsetup MicrosoftWindowsPowerShell or start ocsetup MicrosoftWindowsPowerShell but they have no effect.
4
votes
3answers
3k views

Importing from CSV and sorting by Date

I have the following script that parses an HR output file looking for employees and outputs information such as Hire Dare, First Name, Last Name, Supervisor etc. The problem I have is that in the ...
0
votes
2answers
87 views

Which tool / technology: System management for databases and dependent services

I'm looking for advice on how to enable our team to take down and re-start our company systems for maintenance purposes. The scenario includes several Oracle db machines several MS SQL Server ...
2
votes
3answers
4k views

Powershell script to send e-mails, losing text in e-mail attachment

I have the following function to send e-mails in powershell with attachments: param ( [parameter(Mandatory = $false)] [string]$l ) function SendMail(){ if($e -ine '') { $mail = New-Object System....
0
votes
2answers
2k views

How do I check for available “Automatic Updates” via script / cli

I asked this on superuser, but I think this may have been a more apropriate place. We are trying to automate server reboots, but one of the "gotchas" we are running into are that they want us to ...
1
vote
5answers
2k views

Utility to search and replace text in files including subdirectories in Windows

For Linux, sed and find are an easy option to search and replace in many files including subdirectories. Is there a way to do the same in Windows (with or without PowerShell)?
2
votes
3answers
499 views

SQL Server without Powershell

I'm trying to install SQL Server 2008 Express Edition, and it's demanding Windows Powershell and refusing to proceed with the installation. Is there any way to get it to install without Powershell? (...
1
vote
4answers
4k views

Check existance of domain accounts with Powershell script

Is there a Powershell cmdlet or script to query Active Directory if a given domain account (such as "myDomain\myUser") exists?
2
votes
1answer
465 views

Powershell Remoting Handover Variables

I've opened a Remote Session s1, and like to run a function with Parameters i handover in my scriptblock: Simplified example with Write-Host: $a = "aaa" $b = "bbb" $c = "ccc" $d = "ddd" Write-Host "...
1
vote
2answers
2k views

Powershell Foreach-Object with if statement not working - help!

I have a batch file that takes a computer name as its argument and will install Java JRE on it remotely. Now, Im trying to run this Powershell script to repeatedly call the batch file and install ...
3
votes
1answer
925 views

How to Load commands into your powershell profile to run on starting powershell

I have found a way to load exchange 2010 powershell into powershell running on a windows xp workstation, however there are a few commands that need to run. I was wondering how I could load them into a ...
3
votes
2answers
2k views

Printer monitoring script (PowerShell)

I am going to write a script of some sort to check event viewer in a windows server 2003 for all printjobs, and then write them to a comma delimited textfile like printername_floor_room.txt I am ...
4
votes
3answers
13k views

Why does my PowerShell script hang when called in PSEXEC via a batch (.cmd) file?

I'm trying to remotely execute a PowerShell script using PSEXEC. The PowerShell script is called via a .cmd batch file. The reason we do this is to change the execution policy, run the powershell ...
0
votes
1answer
330 views

Powershell: Conditionally changing objects in the pipeline

I'm converting a CSV to SQL inserts and there's a null-able text column which I need to quote in case it is not NULL. I would write something like the following for the conversion: Import-Csv data....
4
votes
2answers
7k views

Start ELEVATED script from within script

Hallo, I'm playing around with Powershell (relative NewBie) and I'm looking for the easiest way to call a Powershell script with elevated rights from within another script. I know of the runas verb ...
1
vote
2answers
2k views

Get-QADComputer -LdapFilter & NOT operator

I'm having issues excluding an OU from my LDAP filter $DaysAgo = (Get-Date).AddDays(-31) $ft = $DaysAgo.ToFileTime() Get-QADComputer -SizeLimit 0 -IncludeAllProperties -SearchRoot 'DC=My,DC=Domain,...
4
votes
2answers
11k views

Dismount USB External Drive using powershell

I am attempting to dismount an external USB drive using powershell and I cannot successfuly do this. The following script is what I use: #get the Win32Volume object representing the volume I wish to ...
3
votes
2answers
2k views

How to detect when Antivirus is out-of-date with Powershell

Is it possible to use powershell to determine if/when the antivirus was last updated on a Win7 or Win2008 Server machine?
20
votes
7answers
60k views

How to get robocopy running in powershell?

I'm trying to use robocopy inside powershell to mirror some directories on my home machines. Here's my script: param ($configFile) $config = Import-Csv $configFile $what = "/COPYALL /B /SEC/ /MIR" $...
1
vote
1answer
2k views

How to troubleshoot a remote wmi query/access failure?

I'm using Powershell to query a remote computer in a domain for a wmi object, eg: "gwmi -computer test -class win32_bios". I get this error message: Value does not fall within the expected range ...
1
vote
1answer
3k views

Get-QADComputer -LdapFilter & variables

Can I use a variable in and LdapFilter with Get-QADComputer? i.e.: $31DaysAgo = (Get-Date).AddDays(-31) $ft = $31DaysAgo.ToFileTime() $StComps = Get-QADComputer -SizeLimit 0 -IncludeAllProperties -...
6
votes
2answers
2k views

Powershell import-module webadministration

Every time I execute this command invoke-command -computername REMOTEPC -scriptblock { import-module WebAdministration; new-item "$env:systemdrive\inetpub\testsite" -type directory; New-WebSite -Name ...
3
votes
3answers
1k views

Increase number of concurrent shells in PowerShell V2

I'd like to increase number of concurrent shells in PowerShell V2.I tried using the following command ,but I got no luck.The error I got is" Error: Invalid use of command line. Type "winrm -?" for ...
2
votes
3answers
2k views

Powershell Remoting: Howto Run a Comand on multiple Machines with individual Parameters?

For example: Lets say i have 10 servers (Server 1-Server10) and a csv list where i have the servernames and a individual Foldername/Path for each server. How would i create these Folders on each ...
1
vote
2answers
4k views

Powershell Set-Acl fails

While working on a little backup script I try to change the ACL of a file using Set-Acl in Powershell 1 on Vista and always get the following error message: Set-Acl : The security identifier is not ...
0
votes
2answers
3k views

Querying Domain Controller objects using Powershell

Could someone explain to me why this does not work? Import-Module ActiveDirectory $dcs = Get-ADComputer -Filter {DistinguishedName -Like "*Domain Controllers*"} I get no results for this query. ...