Questions tagged [powershell-5.0]

For issues relating to Windows PowerShell, version 5.0

Version 5.0 of Windows PowerShell, Microsoft's task automation and configuration management platform that functions as an interactive command shell and a scripting language. For general information about Windows PowerShell, see the tag wiki for the tag.

Windows PowerShell 5.0 is available as part of the Windows Management Framework (WMF) 5.0.

For the latest news and developments, check out the PowerShell blog.

909 questions
8
votes
1 answer

Deserialized Object type issues - specifically with Powershell 5 classes and Import-CliXml

I'm having issues with Powershell 5 classes and object types when reimporting deserialized objects using the Import-CliXml command. I have an object of type Computer and I wish to store this as xml and then reimport this next time the script is…
8
votes
3 answers

Calling a Function From Another Function in PowerShell

First time in PowerShell 5 and I'm having trouble calling a function that writes messages to a file from another function. The following is a simplified version of what I'm doing. workflow test { function logMessage { param([string]…
8
votes
2 answers

Execution policy prompt the first time powershell script runs after reboot

I have a PowerShell script I wish to use to automate something. I run it by right clicking on it and choosing "Run with PowerShell". I have run Set-ExecutionPolicy Bypass in both 32- and 64-bit PowerShell, and verified it with…
Tor Klingberg
  • 4,790
  • 6
  • 41
  • 51
8
votes
2 answers

PowerShell v5 - How to install modules to a computer having no internet connection?

I've a machine (v3, internet, no admin access) which I used to download WMF 5.0 and set up another machine(v5, no internet, admin access). Now, I want to use some modules from PowerShellGet on the machine running v5 but no internet connection. I…
zerocool18
  • 523
  • 1
  • 4
  • 11
8
votes
1 answer

Get error while running Enable-Migrations

I got below error while running Enable-Migrations on my ASP.NET MVC5 project (Powershell v5 & Visual Studio 2015). I have tried to uninstall and re-install EntityFramework (v6.1.3) but no lucky. Does anyone know how to solve it? Type name…
8
votes
1 answer

Nuget (PowerShell 2.0 Error) Visual Studio 2015, Windows 10 (PwrShl 5.0)

I am using Visual Studio 2015, on Windows 10 - I am having an issue running the Nuget Console, it wants Powershell 2.0. I do infact have powershell installed, but its version 5.0 I don't really understand why 5 wouldn't be compatible with 2? or why…
8
votes
1 answer

New-Object -Property Hashtable not populating fields in Version 5.0 on Win 10

The follow code works fine in PowerShell 4.0 and earlier. If I run it on version 5.0.10240.16384 on the latest Windows 10 build the fields don't populate in the new object ($a). Is this a bug or has something changed? Add-Type @" public struct…
Matt Gartman
  • 867
  • 4
  • 9
7
votes
2 answers

Powershell doesn't load System.Net.Http assembly and ignore Add-Type within script

I'm trying to use HttpClient with a custom HttpClientHandler (to fix a Cookie issue not correctly managed with redirection). Both are into the System.Net.Http assembly (and namespace) and Powershell (and ISE) can't see the classes (nor the…
0xCDCDCDCD
  • 364
  • 1
  • 3
  • 16
7
votes
3 answers

How do we get a drive by its label in PowerShell 5.0?

I have an autorun.inf file with the following contents on my external hard drive: [Autorun] Label=MasterSword This labels my external hard drive once it's plugged in as, MasterSword. I want to store a few scripts on it and include them in my…
ExcellentSP
  • 1,529
  • 4
  • 15
  • 39
7
votes
2 answers

How to convert to UInt64 from a string in Powershell? String-to-number conversion

Consider the following Powershell snippet: [Uint64] $Memory = 1GB [string] $MemoryFromString = "1GB" [Uint64] $ConvertedMemory = [Convert]::ToUInt64($MemoryFromString) The 3rd Line fails with: Exception calling "ToUInt64" with "1" argument(s):…
Mark Allison
  • 6,838
  • 33
  • 102
  • 151
7
votes
1 answer

How to access a property from an object using a variable name?

This works: $psISE.Options.DebugBackgroundColor = '#FFC86400' This doesn't: $attribute = 'DebugBackgroundColor' ($psISE.Options)[$attribute] = '#FFC86400' ERROR: Unable to index into an object of type Microsoft.PowerShell.Host.ISE.ISEOptions I…
jott19
  • 371
  • 3
  • 13
7
votes
2 answers

Configure a DSC Resource to restart

I have a DSC resource that installs dotnet feature and then installs an update to dotnet. In the Local Configuration Manager I have set RebootNodeIfNeeded to $true. After dotnet installs, it does not request a reboot (even used xPendingReboot module…
DamianB
  • 361
  • 2
  • 5
  • 16
7
votes
1 answer

How to explain not working "Tee-Object" when "Select-Object -First" occurs

With the following code, $t equals @(1,2). $t = "before" 1..2 | Tee-Object -Variable t So why is it that the next code snippet has $t equal to "before" instead of @(1)*? $t = "before" 1..2 | Tee-Object -Variable t | Select-Object -First 1 I see…
jjacek
  • 71
  • 3
7
votes
3 answers

New-Item changes function return value

I want to write a function that creates a folder (if it doesn't exist) with specified name inside specified folder. It's turned out that depending on calling New-Item function return different values. And I can't figure out how it's related to…
sad comrade
  • 1,341
  • 19
  • 21
7
votes
2 answers

Windows 10 Powershell Invoke-WebRequest "Windows Security Warning "

Alright this is one big problem in my opinion that Microsoft needs to address immediately. Steps to reproduce this: powershell> Invoke-WebRequest "anywebsitewithcookies.com" (Let's do microsoft.com for example) What happens is that you get the…
John Smith
  • 169
  • 2
  • 11
1 2
3
60 61