Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Sunday, 12 July 2015

Using PowerShell To Check The OS Architecture

This post was actually inspired by the previous post: 


I was thinking using Powershell instead, the previous batch file serves the purpose, check for that particular folder and wah la you got your program installed. But I want to tap on Powershell's advance feature to ensure that the machine is really on 64 bit OS to install. 

So here goes: 

$OSArchitecture = (Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture -ErrorAction Stop).OSArchitecture
if ($OSArchitecture -eq '64-bit')
{& path:\a.exe}
else
{& path:\b.exe}

The idea is to use Powershell to check on the OS architecture. The strings behind Win32_OperatingSystem can be found here

You will need to change the variable yourself for the software path. 

Afterwards you can deploy the a batch file to invoke the above Powershell script to install the programs. Make sure you add in the required installation parameters as well. 

In case you do not know how to use a batch file to run Powershell scripts you can take a look of my previous posts on simple scripting to get the job done: 




Enjoy!

SY

Tuesday, 30 June 2015

Software inventory using PowerShell

SCCM admins get it all the time, they offer received request on either software or hardware inventory, what if for some reason, they just need a list of software that are installed in the client machine (less than five of them) for comparison sake, and it needs to be in CSV format?

Well, you could do that in SCCM reporting. But if you don't have time to look through over 200 report templates for an answer, you could use the below PowerShell command to list out the software name and version that will be exported into a CSV format, the file name will be the host name that you are running Powershell on so that you know which list does it belongs to.


Get-WmiObject -Class Win32_Product | Select-Object name,version |sort-object name | Export-Csv -Path "C:\$env:computername.csv"

Here are some of the little scripts that I have used along to work to get the administration work done. (So far)


1) Clear CCMCache using PowerShell

2) Use batch file command to check OS architecture for software deployment

Have fun!

SY