
A very simple and basic function to show how quickly it is to deploy and install a driver. Add to or modify the snippet anyway you’d like.
INSTALLED COMMANDS
The EXPAND and PNPUTIL are installed as part of a windows installation. I find it a good idea to use what already exists on a machine to do something simple like this. Links change on occasion. If you find these out of date please leave a comment.
- EXPAND
- PNPUTIL
After the drives are copied to local or remote machines, looping thru the machine list actually copies, and run the script block with EXPAND and PNPUTIL executing in sequence. You could add error handling but from command line, if there are errors the ones returned are somewhat helpful.
Function copy-LocalBitsToDestInstallDriver {
#
Any list of computer names will do. But read directly from Azure Subscriptions if you can
#
foreach ($VM in $global:singleSubVms)
{
write-host “—————————————————” -foregroundcolor “White”
$VM.Name
[string]$DestinationMachine = $VM.Name
$source=’\\JosephKravis\TempSpecialDriver’
$destination=”\$DestinationMachine\X$\TempSpecialDriver”
#
To eliminate double hop issue copy bits without Invoke-Command
#
Copy-Item -Recurse -Filter *.cab -path $source -destination $destination -Force
$ScriptBlock = {
Expand X:\TempSpecialDriver\SpecialDriver.cab -F:* X:\TempSpecialDriver
pnputil /add-driver d:\TempSpecialDriver\Special.Driver.inf /install
}
Invoke-Command -Computer $DestinationMachine -ScriptBlock $ScriptBlock
Write-Host $Destination -foregroundcolor “Blue”
}
}
I have a snippets folder that is loaded via my PowerShell profile that this snippet is part of. Never know when I need to install a driver quickly or out of band if you’re the one doing deployments.
Thoughts & Ideas, Joseph Kravis 🙂
Categories: #kravis, #PowerShell, #programming, Automation, PowerShell, PowerShell Posts, Technology
Leave a Reply