1 Reply Latest reply on Mar 24, 2014 8:42 AM by LANDave

    PowerShell task to perform laptop specific provisioning tasks

    jwood8 Apprentice

      Seeing as people liked the last PowerShell script, here's another that we use - this one detects if the machine is a laptop and if so performs certain tasks - we use it to install a VPN client as an example. Modified from an idea by Hey Scripting Guy at Microsoft, plus I added return codes as suggested by David Watson in the other thread - thanks David, good tip! If you're not using those, knock off the Exit lines if you like, if you are then make sure you add matching entries in the package under 'Assign Return Codes'.


      Function Get-Laptop



      [string]$computer = "localhost"


      $isLaptop = $false

      if(Get-WmiObject -Class win32_systemenclosure -ComputerName $computer |

          Where-Object { $_.chassistypes -eq 9 -or $_.chassistypes -eq 10 `

          -or $_.chassistypes -eq 14})

         { $isLaptop = $true }

      if(Get-WmiObject -Class win32_battery -ComputerName $computer)

         { $isLaptop = $true }






                New-Item "C:\I_AM_A_LAPTOP.txt" -type file


                Exit 2020




                New-Item "C:\I_AM_NOT_A_LAPTOP.txt" -type file


                Exit 2021



      We're still testing this so if anyone finds any issues then feel free to chip in, seems to work so far though on our Dell estate. Hope this helps!