Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 通过CIM会话(WMI)散列远程文件。非中小企业_Powershell_Hash_Wmi_Md5 - Fatal编程技术网

Powershell 通过CIM会话(WMI)散列远程文件。非中小企业

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命令来查找文件并计

目标:使用CIM会话(不使用SMB)计算远程文件的MD5哈希

我想在不共享C$的远程windows系统上散列一个文件。我可以通过CIM会话复制远程文件(因此我知道我可以访问该文件),但在尝试下面的代码时,我会出现以下错误:

解析路径:找不到驱动器。名为“CIM_数据文件”的驱动器不存在


没有提供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
}