This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

how to input 'y' or 'yes' with powershell script to NCM

Hello, Team

is anybody who can give me an idea how to input the 'yes' or 'y' command when waiting for the user input.

want to automate the Nexus 3048 ios upgrade process with powershell script with NCM.

Also, powershell script can apply for multiple devices at the same time for example upgrade 100 devices at the same time for 1 powershell script.

for example

Images will be upgraded according to following table:

Module             Image         Running-Version             New-Version  Upg-Required

------  ----------------  ----------------------  ----------------------  ------------

     1            system             6.0(2)U1(2)             6.0(2)U3(1)           yes

     1         kickstart             6.0(2)U1(2)             6.0(2)U3(1)           yes

     1              bios      v1.2.0(08/25/2011)      v1.2.0(08/25/2011)            no

     1         power-seq                    v4.4                    v4.4            no

Switch will be reloaded for disruptive upgrade.

Do you want to continue with the installation (y/n)?  [n] y   <--- here, how to input 'y' command with powershell script ??

Install is in progress, please wait.

Performing runtime checks.

[####################] 100% -- SUCCESS

Setting boot variables.

[####################] 100% -- SUCCESS

Performing configuration copy.

[####################] 100% -- SUCCESS

Finishing the upgrade, switch will reboot in 10 seconds.

as20a.w40216b.x460.krccw#

  • Hello, I don't know which commands are you using, however for such cases is usually used switch "-force" when using the commandlet. Example: set-executionpolicy "bypass" -force

    Does it suit your reqs?

    Honza

  • Hello

    thanks for your your quick response :-)

    i will using following powershell script for the device ios upgrading

    give me an idea for input the 'y' command to the device plz

    ========================================================

    #Prep File

    $File = "C:\file.txt"

    $hostname = "127.0.0.1"

    $username = "admin"

    $password = New-Object System.Security.SecureString

    $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

    $swis = Connect-Swis -v2 -host $hostname -cred $cred

    $ip=read-host "Enter any IP Address"

    $nodeId = get-swisdata $swis "SELECT NodeID FROM Cirrus.Nodes WHERE AgentIP='$ip'"

    $script ="install all kickstart bootflash:n3000-uk9-kickstart.6.0.2.U3.0.709.bin system bootflash:n3000-uk9.6.0.2.U3.0.709.bin"  <--- will be this command executed

    $nodeIdList = New-Object -TypeName "System.Guid[]" 1

    $nodeIdList[0] = $nodeId

    Invoke-SwisVerb $swis Cirrus.ConfigArchive Execute @($nodeIdList, $script, $username) | Out-Null

    $transferID = "{$nodeId}:${username}:ExecuteScript"

    do {

        Start-Sleep -Seconds 1

        $status = Get-SwisData $swis "SELECT T.Status, T.Error FROM Cirrus.TransferQueue T WHERE T.TransferID=@transfer" @{transfer=$transferID}

        #Write-Host $status.Status

    }

    while (($status.Status -ne 'Complete') -and (-not $status.Error))

    $output = Get-SwisData $swis "SELECT T.Log FROM Cirrus.TransferQueue T WHERE T.TransferID=@transfer" @{transfer=$transferID}

    write-host $output

    $output | Out-File $File

    Write-Host "Process Completed!!"

  • Hi leinhard,

    Please try the following modification to your script line:

    $script ="install all kickstart bootflash:n3000-uk9-kickstart.6.0.2.U3.0.709.bin system bootflash:n3000-uk9.6.0.2.U3.0.709.bin${CRLF}yes${CRLF}"  <--- will be this command executed

    If that doesn't work for your device enable session traces in NCM Advanced settings and send us the session trace log.

    Regards,

    Denys.

  • use this script instead for testing

    $script = "reload${CRLF}y${CRLF}"

    and session tracing log is below

    Got 10 bytes

    switch#

    Got 4 bytes

    Got 10 bytes

    switch# terminal width 0

    Got 2 bytes
    te
    Got 106 bytes
    rminal width 0

                           ^
    % Invalid number, range is (24:511) at '^' marker.

    switch# terminal length 0

    Got 2 bytes
    te
    Got 29 bytes
    rminal length 0

    switch# reloady

    Got 7 bytes
    reloady
    Got 65 bytes


                  ^
    % Invalid command at '^' marker.

    switch#

  • Hello, Denys

    can i get the configmgmt-command file for the cisco nexus 3048 device?

    there are serveral pre-command defined, so want to know how to use it.

    for example

    <!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by () -->

    <!--SolarWinds Network Management Tools-->

    <!--Copyright 2005 SolarWinds.Net All rights reserved-->

    <Configuration-Management Device="Cisco 5010 NX-OS VRF Management Devices" SystemOID="1.3.6.1.4.1.9.12.3.1.3.798">

    <Commands>

      <Command Name="RESET" Value="terminal width 0${CRLF}terminal length 0"/>

      <Command Name="Reboot" Value="reload${CRLF}y${CRLF}y"/>

      <Command Name="EnterConfigMode" Value="config terminal"/>

      <Command Name="ExitConfigMode" Value="end"/>

      <Command Name="Startup" Value="startup-config"/>

      <Command Name="Running" Value="running-config"/>

      <Command Name="DownloadConfig" Value="Show ${ConfigType}"/>

      <Command Name="UploadConfig" Value="${EnterConfigMode}${CRLF}${ConfigText}${CRLF}${ExitConfigMode}"/>

      <Command Name="DownloadConfigIndirect" Value="copy ${ConfigType} ${TransferProtocol}://${StorageAddress}/${StorageFilename} vrf management${CRLF}${CRLF}${CRLF}"/>

      <Command Name="UploadConfigIndirect" Value="copy ${TransferProtocol}://${StorageAddress}/${StorageFilename}  ${ConfigType}${CRLF}${CRLF}"/>

      <Command Name="DownloadConfigIndirectSCP" Value="copy ${ConfigType} ${TransferProtocol}://${SCPServerUserName}@${SCPStorageAddress}/${StorageFilename}${CRLF}${CRLF}${CRLF}${CRLF}${SCPServerPassword}"/>

      <Command Name="UploadConfigIndirectSCP" Value="copy ${TransferProtocol}://${SCPServerUserName}@${SCPStorageAddress}/${StorageFilename}  ${ConfigType}${CRLF}${CRLF}${SCPServerPassword}"/>

      <Command Name="EraseConfig" Value="write erase${CRLF}Y"/>

      <Command Name="SaveConfig" Value="copy running startup"/>

      <Command Name="Version" Value="show version"/>

    </Commands>

    </Configuration-Management>

    What is this?? and how can i use this?

    i have no idea at this time..

    Kind Regards

  • i made a command script for nexus 3048

    <!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by () -->

    <!--SolarWinds Network Management Tools-->

    <!--Copyright 2005 SolarWinds.Net All rights reserved-->

    <Configuration-Management Device="Cisco 3048 NX-OS Management Devices" SystemOID="1.3.6.1.4.1.9.12.3.1.3.1106">

      <Commands>

      <Command Name="RESET" Value="terminal width 0${CRLF}terminal length 0"/>

      <Command Name="Reboot" Value="reload${CRLF}y${CRLF}"/>

      <Command Name="EnterConfigMode" Value="config terminal"/>

      <Command Name="ExitConfigMode" Value="end"/>

      <Command Name="Startup" Value="startup-config"/>

      <Command Name="Running" Value="running-config"/>

      <Command Name="DownloadConfig" Value="Show ${ConfigType}"/>

      <Command Name="UploadConfig" Value="${EnterConfigMode}${CRLF}${ConfigText}${CRLF}${ExitConfigMode}"/>

      <Command Name="DownloadConfigIndirect" Value="copy ${ConfigType} ${TransferProtocol}://${StorageAddress}/${StorageFilename} vrf management${CRLF}${CRLF}${CRLF}"/>

      <Command Name="UploadConfigIndirect" Value="copy ${TransferProtocol}://${StorageAddress}/${StorageFilename}  ${ConfigType}${CRLF}${CRLF}"/>

      <Command Name="DownloadConfigIndirectSCP" Value="copy ${ConfigType} ${TransferProtocol}://${SCPServerUserName}@${SCPStorageAddress}/${StorageFilename}${CRLF}${CRLF}${CRLF}${CRLF}${SCPServerPassword}"/>

      <Command Name="UploadConfigIndirectSCP" Value="copy ${TransferProtocol}://${SCPServerUserName}@${SCPStorageAddress}/${StorageFilename}  ${ConfigType}${CRLF}${CRLF}${SCPServerPassword}"/>

      <Command Name="EraseConfig" Value="write erase${CRLF}Y"/>

      <Command Name="SaveConfig" Value="copy running startup"/>

      <Command Name="Version" Value="show version"/>

                    <Command Name="Precommand" Value="y" Delay="1" RegEx="continue?" />

             </Commands>

    </Configuration-Management>