到本地主机的 New-PSSession 失败

2024-03-28

我有一个打开本地主机远程会话的脚本。 我需要这个来从登录脚本中在某些设备上安装 NuGet。

$Username = "Admin"  
$Password = ConvertTo-SecureString ‘adminPW’ -AsPlainText -Force
$adminCredential = New-Object System.Management.Automation.PSCredential $Username, $Password
$Session = New-PSSession  -Credential $adminCredential
Invoke-Command -Session $Session -ScriptBlock {Install-PackageProvider -Name NuGet -Verbose -MinimumVersion 2.8.5.201 -Force}

每次我尝试运行此程序时都会收到以下错误:



New-PSSession : [localhost] Connecting to remote server localhost failed with the following error message : The client cannot connect to the destination 
specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the 
WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the 
destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
At C:\Users\Mike Holtackers\OneDrive - Foreign Trade Association\Scripts\OutlookSig\getAADconnectionOK.ps1:5 char:12
+ $Session = New-PSSession -ConnectionUri $ConnectionURI -Credential $a ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed
  

Running winrm quickconfig并没有改变任何东西...

以下是输出winrm get winrm/config



PS WSMan:\localhost\Listener\Listener_1084132640> winrm get winrm/config
Config
    MaxEnvelopeSizekb = 500
    MaxTimeoutms = 60000
    MaxBatchItems = 32000
    MaxProviderRequests = 4294967295
    Client
        NetworkDelayms = 5000
        URLPrefix = wsman
        AllowUnencrypted = false
        Auth
            Basic = true
            Digest = true
            Kerberos = true
            Negotiate = true
            Certificate = true
            CredSSP = false
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        TrustedHosts = *
    Service
        RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
        MaxConcurrentOperations = 4294967295
        MaxConcurrentOperationsPerUser = 1500
        EnumerationTimeoutms = 240000
        MaxConnections = 300
        MaxPacketRetrievalTimeSeconds = 120
        AllowUnencrypted = false
        Auth
            Basic = false
            Kerberos = true
            Negotiate = true
            Certificate = false
            CredSSP = false
            CbtHardeningLevel = Relaxed
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        IPv4Filter = 194.168.254.1-194.168.254.256 [Source="GPO"]
        IPv6Filter [Source="GPO"]
        EnableCompatibilityHttpListener = false
        EnableCompatibilityHttpsListener = false
        CertificateThumbprint
        AllowRemoteAccess = true [Source="GPO"]
    Winrs
        AllowRemoteShellAccess = true
        IdleTimeout = 7200000
        MaxConcurrentUsers = 2147483647
        MaxShellRunTime = 2147483647
        MaxProcessesPerShell = 2147483647
        MaxMemoryPerShellMB = 2147483647
        MaxShellsPerUser = 2147483647
  

检查是否winrm服务正在您的本地主机上运行:

PS C:\>  Get-Service winrm | ft -AutoSize

Status  Name  DisplayName                              
------  ----  -----------                              
Running winrm Windows Remote Management (WS-Management)

否则 PS 远程处理将无法工作,尽管您已通过 winrm 配置并通过以下方式启用了 PS 远程处理Enable-PSRemoting.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

到本地主机的 New-PSSession 失败 的相关文章

随机推荐

  • 如何将子节点从一个节点复制到另一个节点?

    情况 我需要下载 childNode 然后将其 set 到另一个节点中 问题是我只想在 childNode 的 Score 属性达到 100 时才执行此操作 我应该在何时何地检查帖子的分数是否为 100 或更高 以及如何将它们复制到新索引一
  • jQuery 选择器 jQuery("element") 和 $("element") 有什么区别?

    我以前多次使用过 jQuery 但总是这样使用 document 最近我多次看到有人使用jQuery document 我不知道它们之间的区别 我认为它们是相同的 但我现在有一个非常困难的问题 你知道 jQuery 插件的大部分用途 doc
  • GMSPolyline 非常大的内存峰值

    在允许用户在各种不同类型的地图上显示我们称之为轨迹的复杂位置点列表的 GPS 应用程序中 每个轨迹可以包含 2k 到 10k 个位置点 当轨迹在非 Google 地图类型上呈现时 它们会被大量剪切 修剪和路径简化 这是为了降低内存使用量并提
  • Ubuntu 上的 MonoDevelop 和 libpjsipDll.so 库。系统.DllNotFoundException

    我正在尝试在 Linux 上使用一个名为 libpjsipDll v44 so我从这里得到的http code google com p sipeksdk downloads list http code google com p sipe
  • 使用 strsplit 中长度不等的 ldply

    我正在尝试根据一些分隔符将数据框列拆分为多个列 我在这个网站上找到了各种答案 并且我正在尝试寻找不同的工作方式 我遇到麻烦了ldply 问题是输出strsplit是不同长度元素的列表 这是一些示例数据 有效的数据以及我正在尝试的数据ldpl
  • 哪里可以找到系统调用源代码?

    在 Linux 中 如果我有源代码树 在哪里可以找到所有系统调用的源代码 另外 如果我想查找特定系统调用的源代码和程序集 我可以在终端中输入类似的内容my system call 您需要 Linux 内核源代码才能查看系统调用的实际源代码
  • 在 Gatsby.js 中以编程方式创建多种类型的页面

    我正在使用 GatsbyJS 构建一个网站 我在两个不同的文件夹中有 markdown 文件 content collections and content posts我希望 Gatsby 为每个 Markdown 文件创建一个页面 并使用
  • 在 R / ggplot 中,plotly 没有获取 geom_text

    我有一个 ggplot 它自己工作得很好 但是当我尝试将其导入到plotly api系统中时 geom text似乎不起作用 其他一切都有效 谁能帮我 这是我的 R 版本 R 版本 3 1 2 2014 10 31 和情节版本 0 5 23
  • Android:绝对布局?

    我是安卓新手 我喜欢在任何我想要的地方自由地绘制对象 所以我一直在使用绝对布局 我收到一条消息 要求使用不同的布局 我读到这是因为不同手机的分辨率不同 我的问题是 这是不使用绝对布局的唯一原因吗 我制定了一种使用指标来调整像素的方法 pub
  • UPPAAL 错误 - java.io.IOException:服务器连接丢失

    我正在学习形式验证 我应该使用我刚接触的 UPPAAL 但是 每次启动 UPPAAL 时 都会遇到以下错误 java io IOException Server Connection Lost 有什么办法可以修复这个错误吗 我在 64 位机
  • 将用户从 Google Checkout 映射到 Android 许可响应

    我正在使用 Android 许可 如下所述 http developer android com guide market licensing index html http developer android com guide mark
  • 使用php触发另一个php脚本,然后忽略

    我正在尝试弄清楚该怎么做是这样的 我有一个 php 文件 让我们调用trigger php运行一些 php 代码来启动我们将调用的另一个 php 文件backgroundProcess php开始处理 虽然trigger php需要忽略发生
  • 新手:“rake -T”时出现错误消息

    我在用红宝石企业版对于我的项目 当我检查我所有的耙任务通过运行命令rake T 我收到以下错误消息 You have already activated rake 0 9 2 2 but your Gemfile requires rake
  • Spring Security 访问因缺少角色而被拒绝记录

    对于 Spring Security 中的访问被拒绝登录 是否有开箱即用的解决方案 我想要的基本上是显示用户在收到访问被拒绝异常时缺少哪个角色 如果没有 我必须走上拥有自己的 accessDeniedHandler 的道路 如何访问在该控制
  • RESTful 资源和正交资源问题

    如果我使用的 3 层应用程序具有通过 HTTP 访问的中间层中的面向 RESTful 资源的服务 那么向 UI 层提供正交资源的最佳方式是什么 一个例子是 用户 资源 它具有一个国家 地区的字段 属性 现在在 UI 层中编辑用户时 我希望能
  • WordPress,使用 cookie 进行类别重定向

    我想要实现的目标 当用户访问该网站并选择特定类别时 他们下次访问该网站 回访用户 时 该页面将在该类别部分打开 我认为 通过在访问者单击类别链接 或加载类别页面时 时设置 cookie 这将相当容易做到 当它们返回以下时间时 将读取 coo
  • 在 Django/mod_wsgi 虚拟环境中配置 WSGIPythonHome 的问题

    我在 Windows 10 上运行 Python 3 7 1 和 Apache 2 4 38 我设置了一个虚拟环境 其中包含通过 pip 安装的 Django 2 2 5 和 mod wsgi 4 6 5 在 httpd conf 内部 我
  • 如何获取字符串中所有匹配的位置?

    我有一个专栏flag acumu在 PostgreSQL 的表中 其值如下 SSNSSNNNNNNNNNNNNNNNNNNNNNNNNNNNNSNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN 我需要用 S 显
  • “user-images.githubusercontent.com”上的图像可以删除吗?

    我不小心在 GitHub 上上传了一张我不想放的图片 我原以为出于示例目的 我已经从上传的图像中删除了私人信息 但私人信息仍然存在 它包含诸如主机名之类的内容 我希望这些内容不是公开的 有没有办法从 github 的图像注册表中删除该图像
  • 到本地主机的 New-PSSession 失败

    我有一个打开本地主机远程会话的脚本 我需要这个来从登录脚本中在某些设备上安装 NuGet Username Admin Password ConvertTo SecureString adminPW AsPlainText Force ad