mirror of
https://github.com/jamesstringerparsec/Easy-GPU-PV.git
synced 2024-08-30 18:22:17 +00:00
First version of file copier...
This commit is contained in:
parent
d00a647728
commit
bc1cf441be
48
CopyFilesToVM.ps1
Normal file
48
CopyFilesToVM.ps1
Normal file
@ -0,0 +1,48 @@
|
||||
$hostname = $ENV:COMPUTERNAME
|
||||
$DriveLetter = "F:"
|
||||
|
||||
# Get Third Party drivers used, that are not provided by Microsoft and presumably included in the OS
|
||||
$drivers = Get-WmiObject Win32_PNPSignedDriver | where {$_.DriverProviderName -eq "NVIDIA"}
|
||||
|
||||
New-Item -ItemType Directory -Path "$DriveLetter\windows\system32\HostDriverStore" -Force | Out-Null
|
||||
|
||||
# Initialize the list of detected driver packages as an array
|
||||
$DriverFolders = @()
|
||||
foreach ($d in $drivers) {
|
||||
# We initialize the list of driver files for each driver
|
||||
$DriverFiles = @()
|
||||
# For each driver instance from WMI class Win32_PNPSignedDriver, we compose the related WMI object name from the other WMI driver class, Win32_PNPSignedDriverCIMDataFile
|
||||
$ModifiedDeviceID = $d.DeviceID -replace "\\", "\\"
|
||||
$Antecedent = "\\" + $hostname + "\ROOT\cimv2:Win32_PNPSignedDriver.DeviceID=""$ModifiedDeviceID"""
|
||||
# Get all related driver files for each driver listed in WMI class Win32_PNPSignedDriver
|
||||
$DriverFiles += Get-WmiObject Win32_PNPSignedDriverCIMDataFile | where {$_.Antecedent -eq $Antecedent}
|
||||
$DriverName = $d.DeviceName
|
||||
$DriverID = $d.DeviceID
|
||||
Write-Host "####Driver files for driver with name: $DriverName" -ForegroundColor Green
|
||||
Write-Host "and with DriverID: $DriverID" -ForegroundColor Green
|
||||
if ($DriverName -like "NVIDIA*") {New-Item -ItemType Directory -Path "$driveletter\Windows\System32\drivers\Nvidia Corporation\" -Force | Out-Null}
|
||||
foreach ($i in $DriverFiles) {
|
||||
# We elliminate double backslashes from the file paths
|
||||
$path = $i.Dependent.Split("=")[1] -replace '\\\\', '\'
|
||||
$path2 = $path.Substring(1,$path.Length-2)
|
||||
$InfItem = Get-Item -Path $path2
|
||||
$Version = $InfItem.VersionInfo.FileVersion
|
||||
If ($path2 -like "c:\windows\system32\driverstore\*") {
|
||||
$ParseDestination = $path2.Replace("c:","$driveletter").Replace("driverstore","HostDriverStore")
|
||||
$Destination = $ParseDestination.SubString(0, $ParseDestination.LastIndexOf('\'))
|
||||
New-Item -ItemType Directory -Path "$Destination" -Force | Out-Null
|
||||
Copy-Item $path2 -Destination $Destination -Force
|
||||
Write-Host "Copied $path2 to $Destination" -ForegroundColor Green
|
||||
}
|
||||
Else {
|
||||
$ParseDestination = $path2.Replace("c:", "$driveletter")
|
||||
$Destination = $ParseDestination.Substring(0, $ParseDestination.LastIndexOf('\'))
|
||||
if (!$(Get-Item -Path $Destination -ErrorAction SilentlyContinue).Exists ) {
|
||||
New-Item -ItemType Directory -Path $Destination -Force | Out-Null
|
||||
}
|
||||
Copy-Item $path2 -Destination $DestinationNormal -Force
|
||||
Write-Host "Copied $path2 to $Destination" -ForegroundColor Green
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user