About us

IIS covers the IT solutions to the issues come across now and then in a company IT infrastructure including Operating system, Softwares, Scriptings, securities and reviews.

Thursday, 6 March 2014

PowerShell Script - Stop similar services

This script can be very important when you want to schedule some of the similar service to stop at certain time for the maintenance purposes. I had one incident in which Altiris asset explorer used to malfunction after a while and solution to the issue is stop its service and restart thus I created the script to get rid of the situation. Here below is the example which I used to stop all SQL services at once.

Change the Bold Part as per your need.

$services = Get-Service
Foreach ($service in $services) {
If($service.name –like ‘SQL*’) {
$service.stop()
}
}

Regards,
Baij

PowerShell Scripts - Running on remote host

If you have any powershell script which is working on your local system and the same want to run over remote hosts and get details. Use below as a solution to your request. The very first line determines how variable for getting hostname is determined. I have created one for getting Operating system details.



$computername = (Read-host 'Enter a computer name')
)

get-wmiobject -class win32_operatingsystem -computer $computername | select-object BuildNumber, Caption, ServicePackMajorVersion

Regards, Baij

PowerShell Scripts

 Server inventory


Change the file and software name given in Bold according to your need.

$com = Get-Content C:\FileNAme.txt
foreach($computers in $com){
$cpu = Get-WmiObject -Class Win32_Processor -Computername $computers
$mb =  Get-WmiObject -Class Win32_BaseBoard -Computername $computers
$sn =  Get-WmiObject -Class win32_bios -Computername $computers
$cn =  Get-WmiObject -Class Win32_ComputerSystem -Computername $computers
$os =  Get-WmiObject -Class Win32_OperatingSystem -Computername $computers
$Office = Get-WmiObject -Class Win32_Product -Computername $computers | where {$_.Name -eq "Microsoft Office Standard 2007"}

$props = @{           
    Computername  = $cn.__Server
    SerialNo      = $sn.Serialnumber
    Model         = $cn.Model
    TotalPhysicalMemory = $cn.TotalPhysicalMemory / 1024 / 1024
    Os = $os.Caption
    IE = $IE.Version
    Office = $office.Name
   
    
    }

New-Object PSObject -Property $props | Ft -Autosize}

Regards,
Baij

PowerShell Scripts - Functions Definition

Have Created one function which will fetch Operating Information for multiple computers.

Change the text file name accordingly.

Function Get-Osinfo {
BEGIN{}
Process{
                $computername = $_
                Get-wmiobject –class win32_operatingsystem –computer $computername | select-object BuildNumber, Caption, ServicePackMajorVersion
}
END{}
}

Get-content C:\computers.txt | get-osinfo

Regards
Baij

PowerShell Script - Model, Name, Serial Number

One who is starting to learn powershell this ones for you fella. This is a very basic script to fetch Computer Model, its name and manufacturer serial number which is unique and helps to identify the machine from a lot.This one works from sitting on your own machine and is able to pull the information from multiple computers one by one. What we you have to do is to add every computer name in a text file then it will connect to all those machine one by one and will keep fetching the details for you in an well defined manner.

Change the filename given in bold letters and put computernames in it. Run the below script from powershell only.


$com = Get-Content C:\FileNAme.txt
foreach($computers in $com){
$sn =  Get-WmiObject -Class win32_bios -Computername $computers -EA silentlyContinue
$cn =  Get-WmiObject -Class Win32_ComputerSystem -Computername $computers -EA silentlyContinue
Write-Host $sn.SerialNumber, $cn.Name, $cn.Model

}

Regards, IIS

PowerShell Scripts - File exist or not

In an organisation where software inventory application does not exist Scripts plays a good role. I met one situation where we had to analyse that in how many computers of our organisation has Winzip installed so that licenses can be procured before they raid us and charge the fine upon.Thus inspired me to create a script which would explore the files remotely exist or not.

I have again used the powershell to make this happen. Script would go through the text file which has computer names in it and will execute the same command one by one on all of them.


$colComputers = Get-Content C:\FileName.txt
$ErrorActionPreference = "SilentlyContinue"
foreach ($StrComputer in $colComputers)
{
$GenItems1 = gwmi Win32_ComputerSystem -Comp $StrComputer
$x86Path = 'C:\Program Files (x86)\WinZip\WZCAB.DLL'
if(!$GenItems1){
Write-Host “$StrComputer not found”
}
else
{
Write-Host $StrComputer, (Get-Item $x86Path | Select -ExpandProperty VersionInfo).fileVersion
}
}



Regards,
Baij

PowerShell Scripts - Ping a Series of IP Address

There are many application over the internet which can ping multiple machines and provide you the status however no software is trustworthy unless you know its coding thus should not be used as far as server or important machines are concerned thus created one of which coding is visible and is very easy to implement.

We need to simply change IP address series 10.10.10.$ to what is our requirement and it is just ready for your environment. Track your important servers connectivity using this simple script.

Start

$ping = New-Object System.Net.NetworkInformation.Ping
$i = 0
1..255 | foreach { $ip = “10.10.10.$_”
$Res = $ping.send($ip)
if ($Res.Status -eq “Success”)
{
$result = $ip + ” = Success”
Write-Host $result
$i++
}}

$Hosts = [string]$i + ” Hosts is pingable”


Write-Host $Hosts

Finish

Regards, IIS

PowerShell Scripts - Machine details from AD

It is also possible to fetch the Operating system and Machine name from Active Directory for which simple one line is enough. This script can fetch more in less time as it simply has to connect to active directory database. Other ways to pull the same information is to run a script remotely to each and every computer one by one remotely and then have data. More information can also be added like version, fsdn by just extending the script.

Below script will give away the output in a well defined table and can be used to create dashboard.

Get-ADComputer -Filter * -Property * | Format-Table Name,OperatingSystem -Wrap –Auto 


Same Information can be achieved by using Power shell also.


DSQUERY Computer "OU=OUNAME,DC=india,DC=DOMAINNAME,DC=local" -name COMPName* -scope subtree -limit 0 > C:\ComputerOU.csv


Regards, IIS

Symantec Altiris - Inventory from SQL Database


Altiris is an inventory software from Symantec which provides in depth details of the computers, server, devices in the organization. It has so many templates in built however its feature to fetch the inventory using the console does not convince much and has very complex architecture. Thus it is rather easy to pull inventory from altiris sql database than its console. I succeeded to create several here using sql queries and sharing eventually.

Below sql query will help you to pull the name for Computer, Software, Operating System, Processor in a tabular manner. Please go through the script and change as need be.

Start

Select * from
( SELECT DISTINCT
[Symantec_CMDB].[dbo].[vComputer].Name
,[Symantec_CMDB].[dbo].[Inv_AddRemoveProgram].DisplayName as name1
,[Symantec_CMDB].[dbo].Inv_HW_Computer_System.[Identifying Number]
,[Symantec_CMDB].[dbo].vComputer.[OS Name]
,[Symantec_CMDB].[dbo].[Inv_HW_Processor_Name_Windows].[Processor Name]

FROM [Symantec_CMDB].[dbo].Inv_AddRemoveProgram INNER JOIN [Symantec_CMDB].[dbo].vComputer
ON [Symantec_CMDB].[dbo].Inv_AddRemoveProgram._ResourceGuid = [Symantec_CMDB].[dbo].vComputer.Guid INNER JOIN
[Symantec_CMDB].[dbo].Inv_HW_Computer_System
ON [Symantec_CMDB].[dbo].vComputer.Guid = [Symantec_CMDB].[dbo].Inv_HW_Computer_System._ResourceGuid
INNER JOIN [Symantec_CMDB].[dbo].[Inv_HW_Processor_Name_Windows]
ON [Symantec_CMDB].[dbo].vComputer.Guid = [Symantec_CMDB].[dbo].[Inv_HW_Processor_Name_Windows]._ResourceGuid
)P
PIVOT (
Count(name1)
FOR name1 in ([Microsoft Office Standard 2007]
,[Java(TM) 6 Update 45]
,[WinZip 17.0]
,[Adobe Reader X (10.1.6)]
,[Symantec pcAnywhere]
)
)As PVT
Order by Name

Finish

Regards, IIS

Monday, 3 March 2014

Find Software Installed on Remote Computer

There are many features in the windows itself which can help you to know if a software related to one particular company is installed on remote computer or not. WMIC command is one of them which can help you. It is the inbuilt command of windows and has so many subfeature. Let me let you one them I used to know how many software has been installed on remote computer which is of Microsoft only.

Run the command in command prompt straight.

WMIC /Node:HostName path win32_Product Where (Caption like "%Microsoft%") Get Name, Version


If you want to know about the software from other publisher change Microsoft to others like Adobe, Java or whatever your need be. Also do not forget to change the hostname.

Regards, Baij