小编Pra*_*hag的帖子

如何检查挂起的重启?

我试图了解Windows计算机是否需要重新启动。但是,我的脚本抛出了错误。

powershell "$key = Get-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue"

Error :
Get-Item : A positional parameter cannot be found that accepts argument
'Update\RebootRequired'.
At line:1 char:8
+ $key = Get-Item
HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Aut ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Item], ParameterBindin
   gException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
   .Commands.GetItemCommand
Run Code Online (Sandbox Code Playgroud)

我在“命令提示符”中运行此命令。不知道是什么意思!

registry powershell

5
推荐指数
2
解决办法
3万
查看次数

用于获取物理 CPU 数量的 Powershell 脚本

我尝试使用下面的脚本获取物理 CPU 的数量,但无法获得所需的结果。

get-wmiobject Win32_ComputerSystem
Run Code Online (Sandbox Code Playgroud)

有没有命令可以获取物理CPU的数量

powershell

3
推荐指数
1
解决办法
2万
查看次数

获取ip地址,powershell中的mac地址

我正在尝试获取 ip 地址和 mac 地址。下面的代码工作得很好,但不适用于 Windows R2,有人有什么建议吗?

主要IP

(get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1}).IPAddress | Select-object -index 0
Run Code Online (Sandbox Code Playgroud)

主 MAC:

(Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.ipenabled -EQ $true}).Macaddress | select-object -first 1
Run Code Online (Sandbox Code Playgroud)

powershell mac-address windows-server-2008-r2

1
推荐指数
1
解决办法
1万
查看次数

在Python中处理异常

我编写了Python代码来进行一些计算.在此期间它转换stringfloat.但是有时数字字符串值可能是空的,它给我的时间valueError.我试图在try catch块中保留它,但是它会转到另一个异常块,如下所示.

try:
   float(some value)
except Exception as ValueError:
   print(error message)

except Exception as oserror:
   print(mesage)
Run Code Online (Sandbox Code Playgroud)

它转到os错误块而不是ValueError

python

-1
推荐指数
1
解决办法
39
查看次数