1

我目前正在开发一个 Powershell 脚本,该脚本将在服务器上运行,并每周/每月通过 ssh 连接到数据域的文本列表。从这个列表中,它将遍历每个,连接并运行一个命令以从每个 DD 中获取信息。我之前没有使用过 Powershell,而且我的知识仅限于大学教育水平的 Linux 和标准命令。

该脚本基于以下内容:

http://findnevilleat.blogspot.ca/2013/12/using-powershell-to-check-data-domains.html

我目前正在尝试修改脚本以满足我的需求,但一直停留在输出上。目前我可以通过 ssh 进入每个数据域并使用“df”和 post-comp 提取数据,但获取其他数据对我来说仍然是一个谜。(即使在 EMC 站点上也没有很多资源)。

总而言之,我想知道是否有人知道如何从以下命令中获取更多信息:

  • 系统 - 显示全部/显示型号/显示硬件/显示统计信息
  • filesys - 显示空间

到目前为止,这是我脚本的基本概述:(我为混乱道歉,我只能做这么多的编辑)

          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    
                    }
              }
                #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          }

感谢任何接受/查看我的问题的人。我很感激。

4

0 回答 0