Guest User

Untitled

a guest
Feb 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #********************************************************************/
  2. # Author: Davion Lowe *
  3. # Date: 2/12/2018 *
  4. # Purpose: A script for locating Network adapters for Vm creation *
  5. # *
  6. #********************************************************************\
  7.  
  8.  
  9.  
  10. $num = 0
  11. $dirpath = "C:\tempPsdata\"
  12. mkdir $dirpath
  13. $Datafile = $dirpath + "data.csv"
  14. $J = 0
  15. $total = 0
  16. Get-NetAdapter | select-object InterfaceDescription | ConvertTo-Csv -notypeinformation | Select-Object -skip 1 | set-content -path $Datafile
  17. Get-content $Datafile | ForEach-Object {$J++}
  18. $NetAdapts = 1..$J
  19.  
  20. Get-content $Datafile | ForEach-Object {
  21.  
  22. $NetAdapts[$total] = $_
  23. $total++
  24.  
  25. }
  26. $l= 0
  27. write-host $NetAdapts
  28. foreach ($element in $NetAdapts)
  29. {
  30.  
  31. Write-host "select $l for:"$element
  32. write-host
  33. $l ++
  34. }
  35. $choice = Read-Host "Which network adapter would you like"
  36. write-host
  37. write-host
  38. Write-host "Your choice is" $NetAdapts[$choice]
  39. Write-Host
  40. Read-Host "To Continue press Enter"
  41. Remove-Item $DirPath -Recurse -Force
  42.  
  43. # Line 17 was commented out because at the end of the script, it was being called for unknown reasons.
  44. # when creating your new VM you will use the variable called choice for the adapter name.
Add Comment
Please, Sign In to add comment