Quantcast
Channel: Ivanti User Community : All Content - OS Deployment and Provisioning
Viewing all articles
Browse latest Browse all 1803

PowerShell task to perform laptop specific provisioning tasks

$
0
0

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

{

Param(

[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 }

$isLaptop

}

 

If(get-Laptop)

          {

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

          \\landeskserver\packages$\somelaptopscript.bat

          Exit 2020

          }

else

          {

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

  \\landeskserver\packages$\somedesktopscript.bat

          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!


Viewing all articles
Browse latest Browse all 1803

Trending Articles