Back again
Being that I am new to powershell; I am trying my best to learn it and to get my first function to work completely.
I have this fuction; it does complete but somewhere I must have went wrong in my scripting. I want it logon to a switch using plink; I am using the -l, -pw, and -m plink option at least I think I am. Here is what my function script looks lilke:
$SwitchIP = Get-Content C:\Scripts\Brocadeswitch\switchIP.txt
$SwitchLogon = Get-Content C:\Scripts\Brocadeswitch\SwitchLogon.txt
$SwitchPsswd = Get-Content C:\Scripts\Brocadeswitch\Switchpsswd.txt
$SwitchCliCommand = Get-Content C:\Scripts\Brocadeswitch\SwitchCommand.txt
$SwitchLogFile = "C:\Scripts\Brocadeswitch\Brocade-Log-" + (Get-date -f dd ).tostring() + (Get-date -f MM ).tostring() + ((Get-Date).year).tostring() + ".txt"
Function Get-SwitchInformation
{
param(
[string]$SwitchIP,
[string]$SwitchLogon,
[string]$SwitchPsswd,
[string]$SwitchCliCommand
)
(Get-Date) > $SwitchLogFile
$SwitchIP | % { $_ >> $SwitchLogFile ; & C:\Scripts\Brocadeswitch\plink.exe -l $SwitchLogon -pw $SwitchPsswd -m . $SwitchCliCommand $_ >> $SwitchLogFile}
}
When I run it I get this output.
Tuesday, April 22, 2014 12:32:05 PM
PuTTY Link: command-line connection utility
Release 0.63
Usage: plink [options] [user@]host [command]
("host" can also be a PuTTY saved session name)
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-v show verbose messages
-load sessname Load settings from saved session
-ssh -telnet -rlogin -raw -serial
force use of a particular protocol
-P port connect to specified port
-l user connect with specified username
-batch disable all interactive prompts
The following options only apply to SSH connections:
-pw passw login with specified password
-D [listen-IP:]listen-port
Dynamic SOCKS-based port forwarding
-L [listen-IP:]listen-port:host:port
Forward local port to remote address
-R [listen-IP:]listen-port:host:port
Forward remote port to local address
-X -x enable / disable X11 forwarding
-A -a enable / disable agent forwarding
-t -T enable / disable pty allocation
-1 -2 force use of particular protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-m file read remote command(s) from file
-s remote command is an SSH subsystem (SSH-2 only)
-N don't start a shell/command (SSH-2 only)
-nc host:port
open tunnel in place of session (SSH-2 only)
-sercfg configuration-string (e.g. 19200,8,n,1,X)
Specify the serial configuration (serial only)
not what I was looking for; it was just a basic switch.
Would please tell me a beginner where I am going wrong or a better way to do what I am trying to do.
Thanks