I have a problem with powershell.
I am trying to download a gif from the intranet of our company with a BAT data, but it always say the following error:
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://domain.name/file.name','C:\file.name')"
can anyone help me?
edit: Here is the version of powershell:
sure here is the table:
Name Value
---- -----
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The windows version is Windows 2008 R2
Best regards,
Xplosio
Related
I am using Ubuntu 20 and I have installed powershell to manage Office 365 accounts.
The powershell version is as follows:
Name Value
PSVersion 7.3.1
PSEdition Core
GitCommitId 7.3.1
OS Linux 5.15.0-58-generic #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
When I run the command line with the correct credentials:
Connect-MsolService -Credential $Credentials
I get this error message:
Connect-MsolService: Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
Connect-MsolService: Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
Does any one know why?
Any help would be greatly appreciated...
I am getting the below error when importing the "AzureAD" powershell module. I have installed the module, unable to import it. I have checked to see if there are any prerequisites required, nothing mentioned in GitHub.
Earlier, I was able to install and import "AZ" module.
UPDATE : Resolved one dependency by copying the system.windows.forms.dll, but more runtime errors...
Name Value
---- -----
PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
VERBOSE: Loading module from path 'C:\Program
Files\PowerShell\Modules\AzureAd\2.0.2.76\AzureAd.psd1'. VERBOSE:
Loading 'FormatsToProcess' from path 'C:\Program
Files\PowerShell\Modules\AzureAd\2.0.2.76\AzureAD.Format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module
AzureAd. VERBOSE: Loading module from path 'C:\Program
Files\PowerShell\Modules\AzureAd\2.0.2.76\Microsoft.Open.Azure.AD.CommonLibrary.dll'.
Import-Module : Could not load file or assembly 'System.Windows.Forms,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The system cannot find the file specified. At line:1 char:1
+ Import-Module -Name AzureAd -Scope Global -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
Which .NET version are you using? You may need to update it as this was an issue with older versions. If that doesn't work you can remove the dependency on System.Runtime.InteropServices.RuntimeInformation to get rid of the error in your screenshot.
It seems that the AzureAD Module is not compatible with PowerShell Core due to the WinForms dependency. I have tried both 7.0.0 and 6.2.4 which did not work
However you can install it using the Desktop version of PowerShell. This version works for me.
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Run elevated
Install-Module AzureAD
And then move on...
Import-Module -Name AzureAD
$creds = Get-Credential -Message "Credentials to connect to Azure AD"
Connect-AzureAD -Credential $creds
Get-AzureADCurrentSessionInfo
I have a Windows 10 machine that is running Powershell version 5. When I type in $psversiontable, I get:
PS C:\WINDOWS\system32> $psversiontable
Name Value
---- -----
PSVersion 5.1.14393.1198
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1198
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
When I try to change version by typing in powershell -version 4.0, I still get this:
PS C:\WINDOWS\system32> $psversiontable
Name Value
---- -----
PSVersion 5.1.14393.1198
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1198
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Do you know how I can run version 4?
Thanks!
The short answer is you can't. There is only a special mode for version 2.0.
Otherwise PowerShell is extremely backwards compatible. Even further PowerShell 3.0 and 4.0 can't be installed side-by-side. Sapien wrote a great blog post covering additional details on this
In general barring a very few outlier bugs, code written for PowerShell 3.0 or 4.0 will work with 5.0/5.1
I am attempting to execute a PowerShell script that works fine on a windows 10 PC that has visual studio and all its dependencies installed, but it will not execute on a VM with a fresh installation of windows 10 pro. I've chiseled the script down and determined that the thing it does not like is the definition of a class in the script.
Class Computer {
[String]$Name
[String]$Description
[String]$Type
[String]$Owner
}
The error I get when running the script with nothing but this class definition is:
An error occurred while creating the pipeline.
+CategoryInfo: NotSpecified: (:) [], ParentContainsErrorRecordException
+FullyQualifiedErrorId: RuntimeException
Running $PSVersionTable on the fresh VM:
Name Value
---- -----
PSVersion 5.0.10240.16384
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 10.0.10240.16384
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
Doesn't PowerShell 5.0 have support for classes? Am I missing a .NET framework dependency that isn't installed or enabled by default with a fresh Windows 10 installation?
To get the WMF 5.0 functionaly, please update to the November Update (10.0.10586.0) per The WMF 5.0 release blog.
Note: If you are running Windows 10, you can get the same set of functionality available in WMF 5.0 RTM by updating to the November update of Windows 10 (Version 1511). If you have not already updated your Windows 10 system, select the Start button, then select Settings > Update & security > Windows Update > Check for updates.
I have PowerShell 3.0 installed, and I wish to emulate v1.0
When I launch PowerShell 3.0 with -Version 1 $PSVersionTable reports:
Name Value
---- -----
CLRVersion 2.0.50727.5456
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
If I use the -Version 2 parameter I get the same result
If I use the -Version 3 parameter I get version 3.
Question, why can't I emulate version 1?
Looking at this answer, I don't think you can run 1 & 2 side-by-side without some surgery on the GAC (so it would follow that 1, 2 & 3 don't all co-exist either - only 2 & 3, because 2 & 3 were designed to run side by side). Version 2 was meant to completely replace version 1, AFAICT.
You can not run V1 using the side by side stuff. That was never supported. You CAN run V2 from V3, but not V1.