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)

9
votes
1answer
1k views

What the heck is going on with this AD filter in PowerShell?

I recently wrote this answer and stumbled on something interesting. get-aduser -filter {-not (description -eq "auto")} | measure-object and get-aduser -filter {description -ne "auto"} | ...
1
vote
1answer
208 views

Using Powershell command New-AUDser to set -HomeDrive and -HomeDirectory

I'm trying to create a new user in AD with the New-ADUser command. When i look in the Users and Computers gui, all the parameters i've passed through powershell, is populated to correct fields, ...
4
votes
2answers
817 views

Powershell script to copy file named 'dat' from multiple folders

I am trying to copy a file named 'dat'. This file has no extension. The thing is though that under a Parent Folder 'Personal' I have 500 folders and all of these 500 folders have the 'dat' file. I am ...
11
votes
2answers
39k views

Run Elevated Powershell prompt from command-line

Is there a way to run a Powershell Prompt with Elevated privileges from a command linein Server 2012? Problem is this is 'Minimal Server Interface' mode without full server-gui installed so I can run ...
0
votes
1answer
356 views

Unable to create zip files with shell.application [closed]

The following example doesn't seem to work on my Windows Server 2008 SP2 nor my Windows 7 Pro Sp1. Command: $shellapp = new-object -com shell.application $shellapp Output: Application ...
0
votes
0answers
345 views

Querying boot order with powershell in vsphere

We have any environment with thousands of virtual desktop hosted on a vshpere hypervisor. I'm looking for a way to check the boot order in the bios of each vm to ensure they all are set up properly. ...
2
votes
2answers
320 views

Remove email addresses by policy

Is there any elegant way to remove email addresses from users using automation, Powershell or Exchange Email Address Policies? The platform in question is Exchange 2007. I would like to modify email ...
0
votes
1answer
1k views

PowerShell send-MailMessage fails: “Configuration system failed to initialize”

I am running Server 2003 x86, and I have PowerShell 2.0 installed. When I type send-MailMessage in PowerShell, I get this error: "Configuration system failed to initialize". I get a similar error ...
0
votes
1answer
1k views

Uninstalling KB2506143 (WMF 3.0) from Windows 2008R2 with Exchange 2010 SP2 doesn't work

KB2506143 was installed on Exchange 2010 SP2 machine on Windows 2008 R2. Since WMF 3.0 was installed Rollup Updates cannot be installed as they fail on starting some PowerShell scripts. Normal ...
1
vote
1answer
2k views

SQL Agent Powershell Job Failing with Non-Admin Proxy

I'm attempting to create a SQL Agent job that will run a PowerShell script that is saved on my system. However, the job fails with the following error: A job step received an error at line 1 in a ...
2
votes
1answer
3k views

Mirror directory, only purging files in destination directory older than 7 days

I would like to mirror a directory, but only delete files in the destination directory older than 7 days. Situation: - Directory A is mirrored to Directory B. - A file from Directory A is deleted ...
3
votes
1answer
5k views

Give AD Security Group Exchange Full Access Permission

My company is running Exchange 2007. From time to time, we need to open a user's Mailbox to to various tasks. Until now, we've been logging is as them and using Outlook directly. I'd like to give Full ...
3
votes
1answer
850 views

How can I automatically delete /tmp folder on shared drive?

We have a /tmp folder that people use for temporary stuff. It can be anything and any file. We want to make it so that this automatically deletes (or preferably MOVES to another folder on the same ...
4
votes
1answer
856 views

Diskpart breaking drive letters after powershell script is run

I built a script that mounts (attach) a VHD using Diskpart, cleans out some system files and then unmounts (detach) it. It uses a foreach loop and is suppose to clean multiple VHD using the same drive ...
0
votes
1answer
544 views

Robocopy Copy “For Loop”

I'm trying to create a simple script that will robocopy several folders using the command below. When one folder is done copying, it moves on to the next. Does anyone have a batch/powershell for loop ...
1
vote
2answers
951 views

Exchange 2010 - Mailbox Export much larger than actual size

I issue this command to export the mailbox of a user: New-MailboxExportRequest -Mailbox "user" -FilePath "\\server\share\user.pst" After 2 minutes or so, this file have been generated: Notice the ...
1
vote
1answer
2k views

Send mail on event log error trigger safe check frequency

I want to use powershell to alert me when an error occurs in the event viewer on my new Win2k12 Standard Server, I was thinking I could have the script execute every 10mins but don't want to put any ...
1
vote
0answers
348 views

PowerShell & FileNotFoundException : which file?

I'm trying to follow the instructions in http://technet.microsoft.com/en-us/library/gg697165.aspx, but my powershell script keeps throwing exceptions. It refers to a FileNotFoundException...but I ...
5
votes
1answer
855 views

New event log nowhere to be found after creating in PowerShell

Through PowerShell, I am attempting to create a new event log and write a test entry to it, but it is not showing up the Event Viewer. This is the command I'm using to create a new event log: ...
6
votes
4answers
11k views

Protect foreach loop when empty list

Using Powershell v2.0 I want to delete any files older than X days: $backups = Get-ChildItem -Path $Backuppath | Where-Object {($_.lastwritetime -lt (Get-Date).addDays(-$DaysKeep)) ...
1
vote
0answers
971 views

Detecting missing drivers for Hyper-V Server 2012

Assume I installed Hyper-V Server 2012. Networking is working fine. The server is locked down, only RDP is enabled. Enabling other ports may not be an option as the server is directly connected to ...
0
votes
1answer
165 views

Are there any Graphical PowerShell tools? [closed]

As a developer for the .NET platform, I like to "explore" a platform, framework or API by browsing through the API documentation which explains what everything is - everything is covered and when I ...
3
votes
1answer
458 views

Powershell enters foreach loop with null object

I'm listing all backups in a given directory: $backups = Get-ChildItem -Path $zipFilepath | Where-Object {($_.lastwritetime -lt (Get-Date).addDays(-7)) -and (-not $_.PSIsContainer) -and ($_.Name ...
2
votes
1answer
1k views

(Powershell) Method to return a list of groups where a specific user has 'write member' security

We use a piece of web-based software that users can log on to in order to manage access to shares controlled with AD groups. The list of groups a user can manage are the groups on which they have ...
8
votes
2answers
927 views

Using Diskpart in a PowerShell script won't allow script to reuse drive letter

I built a script that mounts (attach) a VHD using Diskpart, cleans out some system files and then unmounts (detach) it. It uses a foreach loop and is suppose to clean multiple VHD using the same ...
0
votes
2answers
83 views

Copying files from one machine to another

I'm currently generating documentation on one machine, and publishing it to a web server using the following commands in a script: net use "\\someShare" PASSWORD /user:username del /S /Q ...
0
votes
1answer
307 views

Create multiple snapshots on Hyper-V 2012 PowerShell all at once

In the Hyper-V GUI, it is possible to create a collection of snapshots across multiple VMs by selecting multiple VMs, then clicking Snapshot. In PowerShell on Windows Server 2012, you can request ...
4
votes
2answers
11k views

Zipping only files using powershell

I'm trying to zip all the files in a single directory to a different folder as part of a simple backup routine. The code runs ok but doesn't produce a zip file: $srcdir = "H:\Backup" $filename = ...
3
votes
1answer
793 views

Searching users by country, and have the result summed pr. country

I am trying to use Get-AQDUser to get a summed list of users per country. So far a have this $Country = Read-Host "Please Enter the country of which you want to see users " Get-QADUser ...
3
votes
1answer
365 views

Powershell script for setting password expiry

Due to mistakes by the helpdesk staff, I found that over a 100 user accounts in my company AD have been set so that their passwords never expire. To avoid the situation in which all these users ...
13
votes
5answers
28k views

How to properly add .NET assemblies to Powershell session?

I have a .NET assembly (a dll) which is an API to backup software we use here. It contains some properties and methods I would like to take advantage of in my Powershell script(s). However, I am ...
2
votes
3answers
3k views

How can I use shared functions in a remote Powershell session?

I have some Powershell scripts for setting up IIS web applications, message queues, etc. They use a set of shared function libraries we've created - so each script starts with the line . ...
1
vote
1answer
80 views

Remove content of file but not the file itself with windows scripting

How do I strip the content of a file without removing the file itself in a windows scripting environment?
15
votes
3answers
32k views

Windows Server 2012 GUI went missing after removing Active Directory

I'm sorry but i'm stuck in figuring out a problem i'm facing here. I removed the AD feature from server manager and after rebooting, my server 2012 gui wasn't there anymore. There's only command ...
3
votes
1answer
339 views

Write stderror to a file using PowerShell

How do I capture error messages from a PowerShell-launched command in a text file? I searched the Internet for a while and found that supposedly, I should be able to do something like ...
4
votes
1answer
116 views

Is it easy or even possible yet to manage windows firewall with powershell?

I'm doing some POC testing on a server 2012 environment, and during initial firewall configuration I find myself going to the GUI repeatedly when I'd really much rather be able to write a script. I've ...
1
vote
1answer
482 views

powershell: Find all mailboxes on Server Foo whose owners are in AD group Bar

I am unsuccessful at attempting the following - maybe I have not correctly grasped the connection between AD users and Exchange mailboxes, also I often fail at seeing the simple ways for manipulation ...
0
votes
1answer
205 views

Powershell script runs on a Win7 client but not on an Exchange CAS server

I have created a small powershell script to disable active sync for mailboxes when the user is not a member of a specific AD group. This script works perfectly when running it from my Windows 7 ...
2
votes
1answer
2k views

Specify Powershell to run on .NET 3.5 after WMF 3.0 install

I just installed the .NET Framework 4.0 and WMF 3.0 on a Server 2008 R2 SP1 machine that has SharePoint Foundation 2010 installed on it. Now, when I go to Start - All Programs - Microsoft SharePoint ...
0
votes
2answers
794 views

Has NETSH been replaced by PowerShell yet (Dec 2012)

Simple question: Can I avoid using NETSH in Windows Server 2008 R2 and instead use PowerShell CmdLets to manipulate things like HTTP? If so, what are some CmdLets to get me started and are they part ...
1
vote
2answers
5k views

Powershell Get-Process cannot connect to remote computer

I've been struggling with this for a few hours and can't figure this out. I have two Windows 7 computers. One is my workstation that is using Powershell to do administrative maintenance. The other is ...
4
votes
2answers
4k views

View/Find all compressed files on the server?

I need to find all compressed files/folders regardless of file format on a Windows Server 2003 machine. Search options do not provide this capability. Is there a way to list/view all compressed ...
10
votes
1answer
1k views

How to override the default dir alias in Powershell?

I wanted to see colorized filenames when I typed dir in Powershell. So, I added the Set-ChildItemColor function from here to my profile file. I also added this line at the end of the profile file to ...
0
votes
1answer
3k views

How to save event logs “Network Policy and Access Services” on NPS server

We have a Windows Server 2008 R2 Enterprise server with NPS role installed in it. (We dont use NAP). Is there any way, we can save all the event logs in------ Event Viewer -> Custom Views -> ...
1
vote
2answers
1k views

Server 2012 Data Deduplication Skipping Replica VHDs

I'm currently trying to use data deduplication on two seperate Windows Server 2012 Datacenter edition hyper-v hosts. On one, I am trying to dedupe replicas that are still being resync'd every 5 ...
0
votes
1answer
565 views

IIS script privileges with powershell

I've created a script for most of the functions I need when creating a Site for my IIS, however, there is still one thing missing. Namely, I can't seem to find the commands for setting script ...
2
votes
2answers
3k views

Powershell wait for compressing to finish

I have written a PowerShell script that zips the contents of a folder and sends it to a server for backup. The issue is that the copy process doesn't wait for the zip process to finish. I have tried ...
3
votes
1answer
6k views

How do I Setup (Initialize, Partition, and Format) a disk using Powershell?

What is a basic example of going through the setup of a new disk (Initializing it, partitioning it, and formatting) it using powershell?
9
votes
2answers
5k views

How can I compare installed hotfixes between two Windows servers using PowerShell?

I need to compare the installed patches between a dev and production environment using PowerShell. How can I do this?
0
votes
1answer
254 views

Change NTFS Security via Powershell [closed]

I'm looking for a simple Powershell way to set NTFS permissions on a specific folder. Get-Acl "\\fileserver\c$\Program Files\Target" is not even working for me. Any ideas?