I know that $PSScriptRoot is not supported for powershell 2.0 , what is a good alternative ?
also does powershell 2.0 support SelectNodes ?
What are good cmdlets for XML manipulation using 2.0 ?
$PSScriptRoot doe not work, an alternative
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
SelectNodes is supported
Related
I have followed Sitecore 9 installation steps by using this link:
A step by step guide for Sitecore 9 installation on your machine.
I have successfully installed SolR server, then after that, I have registered Sitecore Nuget repository and also installed related module
Install-Module SitecoreInstallFramework
Install-Module SitecoreFundamentals
Import-Module SitecoreInstallFramework
Import-Module SitecoreFundamentals
Then after I have tried to run shell script but got the following exception
.\InstallSitecore9.ps1
Install-SitecoreConfiguration : No registration found for extension 'AppPool' of type 'Task'.
At C:\sitecore\install\InstallSitecore9.ps1:48 char:1
+ Install-SitecoreConfiguration #xconnectParams -Verbose
I found attempting to execute the 9.3 scripts in powershell v7 caused these errors. Switching to a v5 powershell session resolved the issue.
Just review your IIS settings, you may have something like below :
I have just got the same issue and resolved it by running the following cmdlet:
Install-SitecoreConfiguration -Path .\Prerequisites.json
I'm trying to generate client code for C#/asp.net core to consume a service that has a swagger 1.1 specification. (The service is out of my control). Unfortunately most up-to-date tools require at a swagger 1.2 spec. Most tools even require open-api 2.0. Even most converters start at 1.2. Does anybody know a tool to upgrade from 1.1 to 1.2?
I'd even consider a manual rewrite, but I can't find anywhere what changed between 1.1 and 1.2
First of all, 1.2 is also a very old version. Consider converting to OpenAPI 2.0 (used by most tools nowadays) or maybe even OpenAPI 3.0 (the latest version).
Swagger Codegen
Swagger Codegen can generate client/server code from 1.x-3.0 specs, and can also convert Swagger 1.x to OpenAPI 2.0 or 3.0.
To generate a C# client from a Swagger 1.x spec using Codegen CLI v. 2.x:
java -jar swagger-codegen-cli-2.4.0.jar generate
-i http://path/to/spec.json
-l csharp
-o ./csharp-client
To convert Swagger 1.x to OpenAPI 2.0, Codegen CLI v. 2.x with the -l swagger argument to get JSON or -l swagger-yaml to get YAML.
java -jar swagger-codegen-cli-2.4.0.jar generate
-i http://path/to/spec.json
-l swagger
-o ./converted
To convert to OpenAPI 3.0, use Codegen CLI v. 3.x with the -l openapi argument to get JSON or -l openapi-yaml to get YAML.
java -jar swagger-codegen-cli-3.0.3.jar generate
-i http://path/to/spec.json
-l openapi
-o ./converted
API Transformer
API Transformer claims to support Swagger 1.x -> 1.2 / 2.0 / 3.0 conversion.
How can i get microsoft edge browser version using registry or command line?
I don't want to take it from UI.
For Microsoft Edge Legacy, you can get the version from PowerShell with Get-AppxPackage:
> (Get-AppxPackage Microsoft.MicrosoftEdge).Version
44.18214.1000.0
If you want to call this from cmd.exe, you can just call Powershell:
> powershell.exe "(Get-AppxPackage Microsoft.MicrosoftEdge).Version"
44.18214.1000.0
In Windows
The first of all, you need to get the path of the .exe file of the application.
use Get-Item
It is just like Get-AppxPackage. And get the version by adding .VersionInfo.
> (Get-Item "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe").VersionInfo
ProductVersion FileVersion FileName
-------------- ----------- --------
85.0.564.63 85.0.564.63 C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
use wmic
wmic can get the information of the application. And we set the name key for which application you want to check.
> wmic datafile where 'name="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"'
AccessMask Archive Caption Compressed CompressionMethod CreationClassName CreationDate CSCreationClassName CSName Description Drive EightDotThreeFileName Encrypted EncryptionMethod Extension FileName FileSize FileType FSCreationClassName FSName Hidden InstallDate InUseCount LastAccessed LastModified Manufacturer Name Path Readable Status System Version Writeable
1179817 TRUE C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe FALSE CIM_LogicalFile 20200924185451.733609+480 Win32_ComputerSystem DESKTOP-QCUDFJL C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe c: c:\program files (x86)\microsoft\edge\application\msedge.exe FALSE exe msedge 2882448 Application Win32_FileSystem NTFS FALSE 20200924185451.733609+480 20200928200140.091076+480 20200923164851.469016+480 Microsoft Corporation C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe \program files (x86)\microsoft\edge\application\ TRUE OK FALSE 85.0.564.63 TRUE
And then, filter the result by adding get {key} at the end of command.
> wmic datafile where 'name="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"' get version
Version
85.0.564.63
In MacOS
use --version
The application is executed from /Applications/"Microsoft Edge.app"/Contents/MacOS/"Microsoft Edge. Therefor, we can command like the bottom.
$ /Applications/"Microsoft Edge.app"/Contents/MacOS/"Microsoft Edge" --version
Microsoft Edge 85.0.564.63
The older answers to this question seem to address Edge Legacy to the exclusion of Edge Chromium (which is now standard). Adding this answer to more fully outline current options targeting Edge Chromium, specifically.
Windows via Registry
For Windows systems, reading the Edge version from the registry is probably your best bet, since it's consistent even when the installation path varies. Some command-line for reading the installed version of Edge Chromium from the registry. There are a few options for that.
Using Powershell:
(Get-ItemProperty -Path HKCU:\Software\Microsoft\Edge\BLBeacon -Name version).version
Using Powershell and Windows Script Host:
(New-Object -ComObject WScript.Shell).RegRead("HKCU\Software\Microsoft\Edge\BLBeacon\version")
Using Reg Query:
reg query HKCU\Software\Microsoft\Edge\BLBeacon /v version
Windows via Executable
If you have more than one instance of Edge installed (for example, an Edge Dev Channel build) and you want to get the version of a specific installation, you can access the VersionInfo metadata of the Edge executable.
Using Powershell:
(Get-Item "C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion
Using the WMIC tool:
(Note that escaping is required when translating the EXE path into the WMI query)
wmic datafile where 'name="C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"' get Version
Non-Windows via App Binary
For non-Windows installations, running the binary from your shell with the --version flag seems to be the best bet. Your path may vary.
Ubuntu example:
/usr/bin/microsoft-edge --version
Mac OSX example:
/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version
Via Package Managers:
Especially on Linux installations, where Edge is likely to have been installed using a standard package manager, version querying via package management is also a solid option.
Note that this option does only apply if the Edge installation is under package management, which is pretty uncommon in non-Linux userland.
Using apt (Ubuntu):
apt list microsoft-edge
Using Homebrew (Mac OSX):
brew info microsoft-edge
Using Chocolatey (Windows):
choco list -l microsoft-edge
Run the following command:
REG QUERY HKEY_CLASSES_root\AppX3xxs313wwkfjhythsb8q46xdsq8d2cvv\Application /v ApplicationName
Example output:
HKEY_CLASSES_ROOT\AppX3xxs313wwkfjhythsb8q46xdsq8d2cvv\Application
ApplicationName REG_SZ #{Microsoft.MicrosoftEdge_40.15063.674.0_neutral__8wekyb3d8bbwe?ms-resource://Microsoft
.MicrosoftEdge/Resources/AppName}
Now you just need to extract the version, e.g. the 40.15063.674.0.
I am trying to map a drive in PowerShell 2.0 and getting this error?
New-PSDrive –Name ftp –PSProvider FileSystem –Root “\\server\folder” -Credential $credential
The provider does not support the use of credentials. Perform the operation again without specifying credentials.
However, Get-Help New-PSDrive shows -Credential as a valid option?
Is this a version issue in PS?
Is there an alternative way to do the same...I would prefer to keep this within PS (since the drive is PS only then) and not drop out to NET USE - NET USE /d but needs must!
It's a bug in PowerShell 2.0
Workaround from the above link:
$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")
Supposedly fixed in 3.0 (I haven't tested it myself).
If you still get the error after installing KB2819745 (powershell 4) then you might have forgotten Dotnet 4.5.
DotNet 4.5 is a requirement for WinRM 4 / Powershell 4, yet the msu installs without it.
This was the issue i was facing, after installing KB2819745 i still got the error. Install Dotnet 4.5 and then rerun KB2819745. Strangely it will reinstall when you installed dotnet, but without dotnet it says its already installed
echo "pass"| net use \\server\share /user:domain\user
it is also working :)
I tried loading PresentationFramework.dll from .NET 4.0 beta2 in PowerShell v2.0. But it fails with the following error.
PS C:\Windows\system32> [Reflection.Assembly]::LoadFile("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationF
ramework.dll")
Exception calling "LoadFile" with "1" argument(s): "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x8013101B)"
At line:1 char:32
+ [Reflection.Assembly]::LoadFile <<<< ("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationFramework.dll")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
How can I load this DLL file within PowerShell 2.0?
You can't load it. PowerShell is using the .NET 2.0 CLR, and 4.0 DLL files cannot be loaded.
It might be possible to reconfigure PowerShell to run in the newer CLR or host PowerShell in a .NET 4.0 application, but I wouldn't recommend either of those.
Run this code in the administrative mode of PowerShell:
reg add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
I had similar issue on Windows Server 2008 (with PowerShell v2) and I resolved by installing these 2 updates :
Microsoft .NET Framework 4.5.1
https://www.microsoft.com/fr-fr/download/details.aspx?id=40779
PowerShell v4
https://www.microsoft.com/en-US/download/details.aspx?id=40855