Powershell 通过CIM会话(WMI)散列远程文件。非中小企业
目标:使用CIM会话(不使用SMB)计算远程文件的MD5哈希 我想在不共享C$的远程windows系统上散列一个文件。我可以通过CIM会话复制远程文件(因此我知道我可以访问该文件),但在尝试下面的代码时,我会出现以下错误: 解析路径:找不到驱动器。名为“CIM_数据文件”的驱动器不存在Powershell 通过CIM会话(WMI)散列远程文件。非中小企业,powershell,hash,wmi,md5,Powershell,Hash,Wmi,Md5,目标:使用CIM会话(不使用SMB)计算远程文件的MD5哈希 我想在不共享C$的远程windows系统上散列一个文件。我可以通过CIM会话复制远程文件(因此我知道我可以访问该文件),但在尝试下面的代码时,我会出现以下错误: 解析路径:找不到驱动器。名为“CIM_数据文件”的驱动器不存在 没有提供md5方法AFAIK的CIM类。正如您自己发现的,其他非CIM cmdlet不支持CIM路径/-对象。它是Windows服务器吗?如果是这样,您可以使用PSRemoting和Invoke命令来查找文件并计
没有提供md5方法AFAIK的CIM类。正如您自己发现的,其他非CIM cmdlet不支持CIM路径/-对象。它是Windows服务器吗?如果是这样,您可以使用PSRemoting和
Invoke命令来查找文件并计算md5。它使用与CimSession相同的协议(WSMAN)。在最新版本的Windows上,PowerShell远程处理是开箱即用的(甚至在最新版本上),不需要SMB共享。因此,在大多数情况下,它比CIM方便得多。
$ComputerName = "RemoteComputerName"
$CimSession = New-CimSession -ComputerName $ComputerName
$files = Get-CimInstance -CimSession $CimSession -ClassName CIM_DataFile -Filter “Path = '\\Temp\\' AND Extension = 'exe'”
foreach ($file in $files) {
# This works to copy the file, so I know I can access the file. I guess could
# copy the file, then hash it... but I don't want to.
#$newfile = “C:\Test2\$($file.FileName).$($file.Extension)”
#Invoke-CimMethod -InputObject $file -MethodName Copy -Arguments @{Filename = $newfile}
# This is where the errror occurs:
# Resolve-Path : Cannot find drive. A drive with the name 'CIM_DataFile' does
# not exist.
Get-FileHash -Path $file -Algorithm MD5
}