Questions tagged [powershell-4.0]

For topics and problems related specifically to Windows PowerShell 4.0. PowerShell 4.0 shipped with the releases of with Windows 8.1 and Windows 2012 R2. It is available as a download for Windows 7 SP1. For general PowerShell topics, use the `PowerShell` tag.

For general PowerShell information see the tag wiki.

Description of PowerShell-v4.0

Windows PowerShell Microsoft's strategic task automation platform for Windows, and includes a command-line shell and scripting language. PowerShell was designed especially for system administrators.

PowerShell 4.0 ships with Windows 8.1 and Windows 2012 R2 as a built-in package.

Availability

PowerShell 4.0 is also available as a download for Windows 7 SP1. http://www.microsoft.com/en-us/download/details.aspx?id=40855

Notable New Features in 4.0

Resources

A list of fetaures new and changed int Windows PowerShell is available here.

For latest news and development, check out the PowerShell blog

1951 questions
0
votes
2 answers

Downloading Text Files Using Powershell

I'm trying to download and save the text file http://www.gutenberg.org/cache/epub/164/pg164.txt using Powershell. I tried using the code: $curl http://www.gutenberg.org/cache/epub/164/pg164.txt -OutFile verne.txt But instead of saving the text file…
iza
  • 117
  • 5
0
votes
2 answers

In Powershell 5 what is the best way to parse forward slash and backslash from a string

I am accepting arguments to a script file for ServerName and Share. I want to make sure that the user does not add any leading or trailing forward slashes or backslashes. Currently, I am doing this... function validateServerShare($a_server,…
EiEiGuy
  • 1,447
  • 5
  • 18
  • 32
0
votes
1 answer

PowerShell Out-File is not working

The following line of my code simply does not write to file the Out-File command: Move-Item $item.Path $CaminhoCompleto -Force -WhatIf -Verbose | Out-File -Filepath $SaidaTXT -Append -NoClobber On the screen it shows correctly, but the file is…
Glicério
  • 75
  • 1
  • 8
0
votes
1 answer

Powershell - Import local CSV

I have a powershell script that imports a CSV file using this command: $empCsv = Import-Csv "addEmp.csv" I have the csv sitting in the same directory as the script but I'm getting a FileNotFoundException. If I use the command with a path to the CSV…
0
votes
1 answer

How to count the variable storage value and filter which are less than 1

I am trying to extract the group membership count from each of the server I supply. Below script works for that: $computers = gc D:\Samir-PS\serverlist.txt $computers | foreach { $computername = $_ [ADSI]$S = "WinNT://$($env:computername)" …
Samir Jain
  • 41
  • 1
  • 1
  • 9
0
votes
0 answers

Powershell - strange behavior with .split

Can anyone explain the strange behavior with string.split given the following examples. # produces output that appears to split on "n" rather than the newline character (ls alias: | Out-String).Split("\n") # produces output that appears to split on…
galford13x
  • 2,483
  • 4
  • 30
  • 39
0
votes
2 answers

get email attribute from object value - Powershell

is it possible to get corresponding email attribute from object property of user $user = "domainname/someOU/someOU/username" Get-ADUser -Filter { CN -eq $user } -Properties *| Select displayname,emailaddress
tictactoe
  • 11
  • 2
  • 6
0
votes
1 answer

PowerShell recursive direct reports ADSI

I am trying to get a list of everyone under a manager (span of control if you will). I have the code that works with the Active Directory module, but i am not able to figure out how to do it with ADSI. I have tried using this code to…
Travis M
  • 105
  • 1
  • 2
  • 14
0
votes
2 answers

Unable to filter specific properties from ADSI direct reports search

For the past few days i have been trying to get specific properties (Name, Title, etc.) from an ADSI search of someones direct reports with no luck. Here is my current code: $searcher = [adsisearcher]"(samaccountname=$user)" $DirectReports =…
Travis M
  • 105
  • 1
  • 2
  • 14
0
votes
1 answer

powershell while loop not working as expected

I'm having issue with this while loop. Even when the status is returned as online its still stuck in the while loop... any ideas would be amazing :) $instance = "(opsworks instance id)" $status = (Get-OPSInstance -InstanceId $instance -Region…
Stelly
  • 27
  • 1
  • 4
0
votes
1 answer

Hyper-v Export-VM : Provider load failure error in 2012r2

I'm using powershell 4 to export all the VMs in hyper-V and move it to a backup server(nas unix). Export was successful for few VMs and after a while it fails with the following errors: Export-VM : Provider load failure At C:\scripts\test.ps1:37…
0
votes
1 answer

Powershell email attachement

I am trying to create a script to automatically send an email with various attachments. I am having an issue of the of it saying the file is not found. I can confirm that the file is present in the folder. I am unsure why I am getting this error and…
Cameron B
  • 1
  • 1
0
votes
1 answer

Confirm existence of subdirectories

I am writing a script to query a SQL server to aggregate data that I can use to search through various directories. If the folder does not exist it should write the path that does not exist to a text file at the end of the code. I created an array…
Cameron B
  • 1
  • 1
0
votes
1 answer

Can't get desired results from Compare-Object

Sample code: $hosts = Get-View -ViewType hostsystem -Property name,network $clusters = Get-View -ViewType clustercomputeresource -Property name,network,host $hosts | Add-Member -MemberType AliasProperty -Name TEST -value MoRef $clusters |…
Ondrej
  • 1
0
votes
2 answers

Limiting recursion depth when searching for folders

I am trying to limit the recursion depth for a folder search script that I wrote. I am trying to limit to up to five levels deep Essentially I want to get something like this: h:\demo\1st level h:\demo\1st level\2nd level h:\demo\1st level\2nd…
russell
  • 25
  • 10
1 2 3
99
100