Questions tagged [powershell-v4.0]
67 questions
15
votes
5 answers
How can I use PowerShell to enable NTFS compression, in place, on log files older than x days?
I have an application server, running Windows 2012 R2, which generates a high volume of log files, to the point that it runs the application volume out of free space on a semi-regular basis. Due to restrictions from the application itself, I can't…

HopelessN00b
- 53,795
- 33
- 135
- 209
13
votes
1 answer
Avoid truncating error message in Powershell error
I'm getting a Powershell error like this:
PS C:\mydirectory> $Error[0]
Get-WmiObject :
At line:143 char:13
+ $Disk = Get-WmiObject MSCluster_Disk -ComputerName $Resource.OwnerNode -Auth ...
+ …

James Lupolt
- 644
- 1
- 7
- 18
11
votes
2 answers
Powershell: A parameter cannot be found that matches
I am new to the Powershell world. Below is my first script
$sServer = "Fully.Qualified.Computer.Name"
$os = Get-WmiObject -class Win32_OperatingSystem -computername $sServer
$object = New-Object –TypeNamePSObject
$object | Add-Member…

Black Dynamite
- 523
- 2
- 5
- 16
9
votes
3 answers
Howto initiate Windows Update on server core from a PS remote session?
When I am logged in via remote desktop on a Windows Server 2012 R2 Core machine I can trigger the windows update by running sconfig.cmd. This however fails when its getting called within a PS remote session:
Enter-PSSession -ComputerName…

Matthias Güntert
- 2,438
- 12
- 39
- 59
9
votes
4 answers
Can a PowerShell DSC configuration file be created from a current system build?
Is there a way to build a PowerShell desired state configuration (DSC) configuration file from a current system? Opposed of building the entire file from scratch?

Brettski
- 942
- 3
- 20
- 31
6
votes
1 answer
How to access/obtain Powershell DNS Server module on 2012r2?
I'm working on a Server 2012R2 server.
I want to use the comdlets like get-dnsserverresourcerecord in the dns server module for PowerShell.
It is not available in the ISE or in the list of modules.
I have powershell version 4.0. I am operating on…

Mr.Budris
- 215
- 1
- 3
- 10
6
votes
2 answers
Query Powershell Error Object Time Occured
Powershell error objects contain a lot of data but I can't seem to track down the time of occurrence for a given error. Using $Error[0] | fl -f retrieves a lot of information but none that appears to be a date time of when the error was generated. …

Colyn1337
- 2,397
- 2
- 23
- 40
6
votes
2 answers
Invoke-Restmethod breaks script in PS 4.0
I had a Powershell script that used Invoke-RestMethod that was working in powershell 3.0. However, I upgraded to powershell 4.0 to fix a bug in powershell 3. When I did so, my script seems to have stopped working.
$username =…

Brett G
- 2,033
- 2
- 28
- 45
5
votes
1 answer
Get AD Group Member - Different Domains
I've been tasked with exporting the members of a few AD groups to .csv which I've always done in the past using the Get-ADGroupMember command in powershell, specifying the group name, selecting the property I need, and using export-csv.
I seem to…

NoobAdmin
- 51
- 1
- 1
- 2
4
votes
1 answer
new-WindowsImage stalls with 0x8007007E, can't load unattend.dll
I'm trying to convert capture a .VHDX as a .WIM file. The file in question is a syspreped Windows 7 generalized image.
I'm working on Windows 8.1 and I have the Windows ADK installed.
In powershell I issue the command. New-WindowsImafe -capturepath…

user3062206
- 41
- 2
4
votes
1 answer
Unable to install Powershell 4
I am trying to install Windows Powershell 4.0. I use Windows 7 SP1 OS (x64 Bit).
I have downloaded & installed below packages already.
.NET Framework 4.5. (NDP451-KB2858728-x86-x64-AllOS-ENU.exe)
Windows Management Framework 4.0.…

SDG
- 41
- 1
- 1
- 4
3
votes
3 answers
Remote Powershell not working but test-wsman does
I need to script some routine task to execute remotly from a serverA to many hosts but a couple of them fail to execute the script.
If i execute this:
$cred = Get-Credential myUser
Invoke-Command -ComputerName serverB -ScriptBlock{gci d:\}…

Nico Osorio
- 41
- 1
- 1
- 8
3
votes
2 answers
Howto check if a powershell command succeeded or not?
Is it possible to check if a powershell command succeeded or not?
Example:
Set-CASMailbox -Identity:blocks.5 -OWAMailboxPolicy "DoNotExists"
caused the error:
Outlook Web App mailbox policy "DoNotExists" wasn't found. Make sure you typed the…

Sonnenbiene
- 130
- 1
- 1
- 10
3
votes
0 answers
Why does Get-Winevent in parallel workflow wants to use PSRemoting?
I'm building a wrapper script for Get-Winevent to search multiple computers' event logs in parallel, using multiple search criteria.
I'm contructing a XML filter for Get-Winevent, then call this fairly simple workflow:
WorkFlow Get-ParallelEvent {
…

abstrask
- 1,688
- 14
- 24
3
votes
1 answer
Delete only files leaving empty sub-folders using powershell
C:\Temp\ifc has about 297 folders inside it with roughly 4.1 million files spread amongst them.
Using a script I found elsewhere on this site, I wrote the following to delete all 'files' which are older than 1 hour.
$TargetFolder =…

Gareth Doherty
- 33
- 1
- 3