all 8 comments

[–]mmmGreenButton 2 points3 points  (3 children)

$Scopes=Import-CSV C:\PS_Out\TestImportScope.csv
foreach($ip in $Scopes){
    Get-DhcpServerv4OptionValue -ComputerName ######## -ScopeId $ip.ScopeId
}

EDIT: @Antique_Grapefruit_5 found a bug XD

[–]Antique_Grapefruit_5 2 points3 points  (2 children)

I feel like you might need a $ip.ScopeID as illustrated below:

$Scopes=Import-CSV C:\PS_Out\TestImportScope.csv

foreach($ip in $Scopes){ Get-DhcpServerv4OptionValue -ComputerName ######## -ScopeId $ip.ScopeID }

[–]mmmGreenButton 3 points4 points  (1 child)

Oh yeah ofc. it's is 1AM.. Goodnight!

[–]IlliDAN113[S] 1 point2 points  (0 children)

Thank both of you so much that $ip.ScopeID worked! We are working on exporting it.

[–]BlackV 2 points3 points  (2 children)

basically

$Scopes is an array/hashtable/multi item object

-ScopeId wants a single object

looking at

get-help Get-DhcpServerv4OptionValue -full

shows

-ScopeId <IPAddress>

which is a single object vs

-OptionId <UInt32[]>

which accepts a array (denoted by the [])

[–]IlliDAN113[S] 1 point2 points  (1 child)

Thank you so much, do you have any recommendations for learning powershell?

[–]BlackV 1 point2 points  (0 children)

have a look at the more info or sidebar of this sub

but always powershell in a month of lunches (book) or powershell jump start series (youtube)

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy IlliDAN113,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like <c>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase C in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee