Bill Stewart가 언급 한 것처럼 매핑 된 드라이브는 사용자별로 있습니다. 값은 각 사용자의 레지스트리에 저장됩니다. 다음은 PSRemoting을 통해 각 사용자의 HKCU:\Network
및 HKCU:\Volatile Environment
(AD 홈 공유에서 매핑 된 드라이브)의 정보를 가져 오는 기능입니다. PDQ 배포 스크립트가 실패하는 이유에 대해서는
function Get-MappedDrive {
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param (
[Parameter(Mandatory = $True,
ValueFromPipelineByPropertyName = $True,
Position = 0)]
[string[]]$ComputerName
)
begin {}
process {
if ($pscmdlet.ShouldProcess($ComputerName)) {
Invoke-Command -ComputerName $ComputerName {
New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | Out-Null
Get-ChildItem HKU:\ |
ForEach-Object {Get-ChildItem "$($_.pspath)\Network" -ErrorAction SilentlyContinue} |
ForEach-Object {
[PSCustomObject]@{
User = (New-Object System.Security.Principal.SecurityIdentifier ($_.name -replace 'HKEY_USERS\\(.*?)\\.*','$1')).Translate([System.Security.Principal.NTAccount]).Value
Drive = "$((Split-Path $_.name -Leaf).ToUpper()):"
Path = Get-ItemProperty -Path $_.PSPath -Name RemotePath | Select-Object -ExpandProperty RemotePath
}
}
Get-ChildItem HKU:\ |
ForEach-Object {
if (Get-ItemProperty -Path "$($_.PSPath)\Volatile Environment" -name HOMEDRIVE -ErrorAction SilentlyContinue) {
[PSCustomObject]@{
User = (New-Object System.Security.Principal.SecurityIdentifier ($_.name -replace 'HKEY_USERS.(.*?)(\\.*|$)','$1')).Translate([System.Security.Principal.NTAccount]).Value
Drive = Get-ItemProperty -Path "$($_.PSPath)\Volatile Environment" -name HOMEDRIVE | Select-Object -ExpandProperty HOMEDRIVE
Path = Get-ItemProperty -Path "$($_.PSPath)\Volatile Environment" -name HOMESHARE | Select-Object -ExpandProperty HOMESHARE
}
}
}
Remove-PSDrive HKU | Out-Null
}
}
}
end {}
}
은 PowerShell 스크립트 파일 공유에 허가없이 계정으로 실행되고 있다는 점이다. net use \\server\folder username password
또는 (New-Object -ComObject WScript.Network).MapNetworkDrive('Z:','\\server\folder',$false, 'username', 'password')
을 사용하여 다른 자격 증명으로 공유를 매핑 할 수 있습니다.
매핑 된 드라이브는 컴퓨터가 아닌 사용자 별입니다. –