- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这个针对Windows [1]的自我解答的问题解决了以下几个方面:
现在有两个PowerShell版本-遗留版本(仅限Windows)Windows PowerShell 和跨平台PowerShell Core ,都可以安装在给定的Windows计算机上:
Invoke-Command -ComputerName
? Enable-PSRemoting
来按需重新启用PowerShell远程处理:
-HostName
参数而不是通过指定目标计算机-ComputerName
参数。 -Authentication Basic -UseSsl
参数的远程cmdlet。 最佳答案
注意:正在考虑默认更改远程端点PowerShell [Core]的目标(从7.0版开始仍然是Window PowerShell):请参阅this GitHub issue。
这是本地指定的远程 session 配置,它确定在远程计算机上将使用哪种PowerShell版本以及可能的版本:
-ConfigurationName
参数诸如Invoke-Command
,New-PSSession
和Enter-PSSession
显式指定 session 配置。 $PSSessionConfigurationName
preference variable持久地通过设置默认的 session 配置(链接的帮助主题还讨论了其他与远程 session 相关的首选项变量,即$PSSessionApplicationName
和$PSSessionOption
)microsoft.powershell
(请参见下文)。因此,您可以替代地在远程目标计算机上更改此配置的定义,但是请注意,这意味着所有使用默认设置的客户端都将使用重新定义的配置-有关如何实现此重新定义的信息,请参见底部。 Get-PSSessionConfiguration
cmdlet列出了客户端可以用来连接的所有已注册 session 配置,您可以使用Register-PSSessionConfiguration
和Unregister-PSSessionConfiguration
对其进行管理:Get-PSSessionConfiguration
必须在提升的 session 中运行(以管理员身份),并且由于Windows PowerShell 5.1中的错误,您可能必须首先运行以下虚拟命令:$null = Get-Command Test-WSMan
,以确保wsman:
驱动器被定义为)。 'microsoft.powershell
'属于Windows PowerShell 。 'PowerShell.'
是指PowerShell 核心。 $PSSessionConfigurationName
均默认为'http://schemas.microsoft.com/powershell/Microsoft.PowerShell'
,这意味着 Windows PowerShell默认情况下针对远程计算机,即使您从PowerShell Core 运行:Microsoft.PowerShell
部分指的是(64位)Windows PowerShell session 配置,由Get-PSSessionConfiguration
列出(小写)。 http://schemas.microsoft.com/powershell/
前缀是可选的,可以省略。请注意,在前缀中使用https:
无效,并且不会自动切换到基于SSL的传输;对于后者,需要explicit configuration。请注意,如果所有远程处理都在Windows域中进行,则不需要基于HTTPS / SSL的远程处理。 PowerShell.7
。PowerShell.7.1.2
Get-PSSessionConfiguration
,会告诉您所有已注册 session 配置的名称。 -ConfigurationName PowerShell.7
,例如:# Connect to computer $comp and make it execute $PSVersionTable
# in PowerShell Core v7.x, which tells you what PowerShell edition
# and version is running.
Invoke-Command -ComputerName $comp -ConfigurationName PowerShell.7 { $PSVersionTable }
$PROFILE
文件中添加以下内容:# When remoting, default to running PowerShell Core v7.x on the
# the target machines:
$PSSessionConfigurationName = 'PowerShell.7'
microsoft.powershell
session 配置,这需要管理特权;您可以改写以下代码段:# Run WITH ELEVATION (as administrator) and
# ONLY IF YOU UNDERSTAND THE IMPLICATIONS.
$ErrorActionPreference = 'Stop'
# The configuration whose definition you want to make the new default.
$newDefaultConfigSource = 'PowerShell.7'
# Standard registry locations and names.
$defaultConfigName = 'Microsoft.PowerShell'
$configXmlValueName = 'ConfigXml'
$configRootKey = 'registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Plugin'
# Rename the current default configuration XML to "ConfigXml.OLD" to keep a backup.
Rename-ItemProperty $configRootKey\$defaultConfigName $configXmlValueName -NewName "$configXmlValueName.OLD"
# Get the configuration XML from the configuration that should become the new default.
# Modify it to replace the source configuration name with the default configuration name.
$xmlText = (Get-ItemPropertyValue $configRootKey\$newDefaultConfigSource $configXmlValueName) -replace
('\b{0}\b' -f [regex]::Escape($newDefaultConfigSource)), $defaultConfigName
# Save the modified XML as the default configuration's config XML.
Set-ItemProperty $configRootKey\$defaultConfigName $configXmlValueName $xmlText
# Restart the WinRM service for changes to take effect.
Restart-Service WinRM
关于powershell - PowerShell远程处理:控制目标版本(PowerShell Core或Windows PowerShell);跨平台远程处理的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58238481/
我正在寻找实现 PowerShell 提供程序 在 电源外壳。 我一直在想,如果我只是定义类型,然后将它们导入我的 session (导入模块),我应该能够让它们可用。 例如,这个 不工作但它沿着我想
我创建的脚本使用了组件,这些组件仅在32位版本的Powershell中可用。 默认情况下,Windows使用Powershell x64执行脚本,这会导致一些错误。 是一种在脚本开头设置值以强制Win
是否可以从 Powershell 中检测它是否是嵌套 shell? 如果我打开 Powershell 或 cmd.exe 窗口,然后输入 powershell 在那里,是否有一个神奇的 $host.s
随着 PowerShell Core 的发布,应用程序在使用托管自动化库 (system.management.automation) 时如何选择调用哪个版本的 Powershell(Powershe
最近,我加入了我企业的 Windows 团队,凭借我的开发人员背景(一般是 Java、.NET 和 Web),我很快就对 PowerShell 产生了兴趣。我可以看到它比普通的旧批处理文件、VB 更有
假设我有一个 powershell 脚本,它在我当前路径的相对路径中包含一个 Powershell 哈希。让我们称之为“name.ps1”,它包含: $names = @{ "bob" = "b
我想为我正在构建的自定义 Powershell Commandlet 使用 SqlServerCmdletSnapin。如果我将以下代码添加到 PSM1 的开头: if ( (Get-PSSnapin
如何调用从 PowerShell 脚本中获取命名参数的 PowerShell 脚本? foo.ps1: param( [Parameter(Mandatory=$true)][String]$a=''
我即将为 Windows 管理员编写一个 PowerShell 脚本,以帮助他们完成与部署 Web 应用程序相关的某些任务。 有什么理由让我应该赞成或排除开发 PowerShell 模块 (.psm1
我的 powershell 模块有一个函数,我希望它返回一个非零退出代码。但是,作为一个模块函数,当我运行 Import-Module 时,它会加载到 powershell 控制台的上下文中。所以,当
我在这个问题上花了最后 4 个小时,非常感谢您提供的任何意见。 我需要使用不同的凭据调用 powershell 脚本并将参数传递给该脚本。 安装 WISEScript 中包装的程序后,此脚本开始收集机
我有一个场景,我需要将 powershell 命令的命令和输出转发到另一个进程以进行日志记录和处理。 我希望这个控制台尽可能接近 powershell,因此不希望将它简单地托管在另一个控制台程序中。
我正在尝试让一个主 PowerShell 脚本运行所有其他脚本,同时等待 30-60 秒以确保完成任务。我尝试过的所有其他操作都不会停止/等待第一个脚本及其进程完成,然后才能同时完成所有其他脚本,并且
我正在编写一个脚本来使用多个 plink (PuTTY) session 作为 Windows 版本的 clustersh。然而,我陷入困境,因为我想从 powershell 打开多个 Powersh
我读了这个答案:How to Open Powershell from Powershell start powershell 这将打开基础的大分辨率 PS 实例。如何打开 PS(x86)? 最佳答案
我很想知道我们是否可以在 Powershell 中做到这一点。 使用 Out-File 命令,我们可以通过管道将其输出写入文件。这样我就可以将我所有的历史命令发送到一个文本文件中。 问题是我可以在每次
我在 about_Pipelines 阅读了有关 PowerShell 中的管道工作原理的信息,并了解到管道一次传送一个对象。 所以,这个 Get-Service | Format-Table -Pr
我正在尝试像这样从 powershell 启动一个进程:- $proc = (start-process $myExe -argumentList '/myArg True' -windowStyle
## To run the script # .\get_status.ps1 -Hostname -Service_Action -Service_Name #$Hostname = "hos
让我们使用 powershell 命令 Write-Host "red text"-Fore red这会在红色前景中显示“红色文本”。 但是,您希望文本以稍微亮一点的方式显示字体颜色,浅红色。 有没有
我是一名优秀的程序员,十分优秀!