Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #********************************************************************/
- # Author: Davion Lowe *
- # Date: 2/12/2018 *
- # Purpose: A script for locating Network adapters for Vm creation *
- # *
- #********************************************************************\
- $num = 0
- $dirpath = "C:\tempPsdata\"
- mkdir $dirpath
- $Datafile = $dirpath + "data.csv"
- $J = 0
- $total = 0
- Get-NetAdapter | select-object InterfaceDescription | ConvertTo-Csv -notypeinformation | Select-Object -skip 1 | set-content -path $Datafile
- Get-content $Datafile | ForEach-Object {$J++}
- $NetAdapts = 1..$J
- Get-content $Datafile | ForEach-Object {
- $NetAdapts[$total] = $_
- $total++
- }
- $l= 0
- write-host $NetAdapts
- foreach ($element in $NetAdapts)
- {
- Write-host "select $l for:"$element
- write-host
- $l ++
- }
- $choice = Read-Host "Which network adapter would you like"
- write-host
- write-host
- Write-host "Your choice is" $NetAdapts[$choice]
- Write-Host
- Read-Host "To Continue press Enter"
- Remove-Item $DirPath -Recurse -Force
- # Line 17 was commented out because at the end of the script, it was being called for unknown reasons.
- # when creating your new VM you will use the variable called choice for the adapter name.
Add Comment
Please, Sign In to add comment