【发布时间】:2018-09-13 16:46:30
【问题描述】:
我有一个数字,让我们使用11 作为示例值。我有名为(在本例中)0266AP1, 0266AP2, 0266AP3, 0266AP4 等的访问点。 0266 是站点/商店编号。
通过调用 Cisco Prime API,我可以看到站点 0266 有 11 个接入点。为了让真正的快速列表传递给我的控制器,我想要做的是递增,直到达到11 或@count 的值。
Function Get-AllApNames {
Write-Verbose "Getting all APs for Store $Store"
$req = "https://cpist/webacs/api/v3/data/AccessPointDetails.json?.group=$Store"
Write-Verbose "Making request to $storeApReq"
$idReq = Invoke-RestMethod -uri $storeApReq -method Get -ContentType 'application/json' -headers @{ Authorization = $auth }
Write-Log "Making Get request to $storeApReq" -Level INFO -logfile $logFile
$apIdCount = $apIdListReq.queryResponse."@count"
$apArray = New-Object System.Collections.ArrayList
}
我已经删除了我的尝试,因为它们都是空的,但我基本上想使用 $apIdCount 作为我的停止点,并使用 1 作为我的起点。
解决方案 1:
Function Get-AllApNames {
Write-Verbose "Getting all APs for Store $Store"
$req = "https://cpist/webacs/api/v3/data/AccessPointDetails.json?.group=$Store"
Write-Verbose "Making request to $storeApReq"
$idReq = Invoke-RestMethod -uri $storeApReq -method Get -ContentType 'application/json' -headers @{ Authorization = $auth }
Write-Log "Making Get request to $storeApReq" -Level INFO -logfile $logFile
$apIdCount = $apIdListReq.queryResponse."@count"
$apArray = New-Object System.Collections.ArrayList
$apLoop = 1..$apIdCount
foreach($i in $apLoop) {
$accPt = $Store + 'AP' + $i
Write-Host $accPt
}
}
【问题讨论】:
标签: powershell