I'm currently working on a Powershell script that will run on a server and ssh to a text list of data domains on a weekly/monthly basis. From this list, it will loop through each, connecting and running a command to grab information from each DD. I have no experience with Powershell prior, and my knowledge is limited to university-education levels of Linux and standard commands.
The script was based off the following:
http://findnevilleat.blogspot.ca/2013/12/using-powershell-to-check-data-domains.html
I'm currently trying to modify the script to meet my needs but have been stuck on the output. Currently I can ssh into each data domain and pull out data with "df" and post-comp but to grab other data is still a mystery to me.(There aren't alot of sources even on the EMC site).
To summarize, I am wondering if anyone has any idea how to grab more information from the following commands:
- system - show all/ show modelno/ show hardware/ show stats
- filesys - show space
Here is a basic overview of my script so far: ( I apologize for the mess, I could only do so much editing)
WriteLog "Checking Data Domain Available Space" $includeList="Cleanable GiB|--------|/data: post-comp" #Data domain format command to print $DB = Get-Content $answerfile #inputstream from file foreach ($Data in $DB){ ##bracket required on same line for foreach / foreach for iteration through data domains $hostname = $Data.Trim() #gets host name without new line character for the SSH command. #~~~~~~~~~ Password Set up ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if($hostname -eq "139.12.34.56" -Or $hostname -eq "10.123.11.108") ##if hostname is one of the selected, change password to correct { $passwd = "12345PASS" } else #all other servers require this secondary password { $passwd = "54321PASS" } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Options: Hardcoded(current) / Read write from file. # With more passwords: Hardcoded = Switch # ReadWrite = Add to list #~~~~~~~~~~ SSH command and exe command Set up Process~~~~~~~~~~~~~~~~~ $exe = "CMD" #Launch CMD for use $command = "/C $plinkcommand $user@$Data -pw ""$passwd"" df" #ssh command $Data > #$command2 = "/C $plinkcommand $user@$Data -pw ""$passwd"" System show preformance" #ETC #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Currently supporting structure(below) to run other commands # Commands to be added: System - (show all, show modelno, show compression, show hardware, show stats) # Filesys - Show space # Possibly more to be added at a later time #~~~~~~~~~~~~~ Navigation of directories in host computer ~~~~~~~~~~~~~~ invoke-expression "cd /" #Change directory to Root invoke-expression "cd /users/kevindong/documents/powershellscripts" #change directory to plink location #Set up command to navigate to plink (requires set up dependedant on computer) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Possible update to "invoke-expression", and possible specific targeted location of operating file directory #~~~~~~~~~~~~~ Execution of SSH data grab commands ~~~~~~~~~~~~~~~~~~~~~ $outputcontents = &$exe $command ##ssh connect execution + "df" command if ($outputcontents -ne "") #if SSH is not null { $outputcontents | ForEach-Object { #foreach requires bracket on same line if ($_ -match $includeList) { WriteLog $_ } #run data collection #add commands here and write log them } } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }
Thank you to anyone who took/takes a look into my problem. I appreciate it.