Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

PowerShell Help !!!

$
0
0

I am very new to PowerShell.  I have a large scale of Brocade Fibre Switch in my environment. I am trying to create a PowerShell script that would make my switch management life a little easier. The script have the following variables;

 

BSSip map to a text file with ip address of the switches .

BCSlogon map to a text file with the user id.

BCSpw map to a text file with the password for the logon id.

BCScommand map to a text file with the command I wish to run on the switch.

 

When I run the PowerShell script can variables has collected the content of the text files asrequested.I get the following error “Unable to open command file “switchshow”

I aslo need to press CTR-C on the switch after logging on.

 

Would someone please the correction of my errors in this script; and other possible ways I complet the task I am trying to do.

 

Thanks in Advance.

Robert

Powershell Script.

<#
This script will login to fibre listed in the switchIP text file  and capture the command and export out to a text file
#>
# Get the IP address from switchIP text file
$BCSip = Get-Content c:\Scripts\Brocadeswitch\switchIP.txt

# Get the logon from SwitchLogon text file
$BCSlogon = Get-Content c:\Scripts\Brocadeswitch\SwitchLogon.txt

# Get the password form Switchpsswd text file
$BCSpw = Get-Content  c:\Scripts\Brocadeswitch\Switchpsswd.txt

# Get the switch command from SwitchCommand text file
$BCScommand = Get-Content c:\Scripts\Brocadeswitch\SwitchCommand.txt

# Use plink to ssh into the switch
$plink = "c:\Scripts\Brocadeswitch\plink.exe"

$logFile = "Brocade-Log-" + (Get-date -f dd ).tostring() + (Get-date -f MM ).tostring() + ((Get-Date).year).tostring() + ".err"


(Get-Date) > $logFile

$BCSip | % { $_ >> $logFile; & $plink -l $BCSlogon  -pw $BCSpw -m $BCScommand $_ >> $logFile }

echo $logFile

 

 

 


Viewing all articles
Browse latest Browse all 10624

Trending Articles