我已经使用powershell命令将.I输出到csv文件,输出如下 Location IP Name
east System.Object[] System.Object[]
wast System.Object[] System.Object[] 为了删除System.Object,我在powershell脚本中使用了-join ',‘作为IP和Name。然后,我得到了合并了行的输出,如下所示 Location IP Name
east
我已经编写了一个Powershell脚本,它使用psftp.exe来备份来自多个交换机的配置文件。改编自的psftp循环的核心如下:
# set up array of psftp commands to run on each switch
$cmd = @("get $config_file_on_switch $local_filename","quit")
#
# pipe those commands to a psftp call
$cmd | & $path_to_PSFTP -l $user -pw $password $IP_addr_
Powershell绝对不是我的“强项”之一,但每隔一段时间,我都会尝试编写一些脚本来自动执行手动任务。无论如何,这是我的问题所在。该脚本按原样工作,并将导出csv文件并按主机名头排序。我的问题是,有没有更好的方法来做这件事?
#Clear the output screen
cls
#set the working directory to where the script and text files are located (must be same directory)
$scriptdir = Split-Path -Parent $PSCommandPath
cd $script
是否有Powershell脚本,或者如果vm有多个ip地址,我如何修改这个脚本以导入多个ips作为csv文件?这是我现有的脚本
# Create Report Array
$report = @()
# Get all the VMs from the selected subscription
$vms = Get-AzVM
# Get all the Network Interfaces
$nics = Get-AzNetworkInterface | Where-Object { $_.VirtualMachine -NE $null }
foreach ($nic in $ni