![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | why is $_.Name null for this? I want to rename all my distribution groups display names to ahve a ~ in front (just changing the display name to better organize our GAL). Why does $_.Name come back null in this? Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" + $_.Name) |
My System Specs![]() |
| | #2 (permalink) |
| | Re: why is $_.Name null for this? Can you try this? Get-DistributionGroup | Set-DistributionGroup -Displayname {"~$_.Name"} -whatif or Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup -Displayname {"~$_.Name"} -whatif Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject J> I want to rename all my distribution groups display names to ahve a ~ J> in front (just changing the display name to better organize our GAL). J> Why does $_.Name come back null in this? J> J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" + J> $_.Name) J> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: why is $_.Name null for this? thanks for showing me the -whatif switch (just learned of it). However, it doesn't seem to tell me what it would do to the group, just the groups that it would ahve effected..not what it would ahve done to them. when I tried to run it agaist a specific group it changed the display name to "~$_.Name" here was the test line I tried: Get-DistributionGroup -identity DEPT-CAPE-IT | Set-DistributionGroup -Displayname {"~$_.Name"} -whatif "Brandon Shell [MVP]" wrote: Quote: > Can you try this? > > Get-DistributionGroup | Set-DistributionGroup -Displayname {"~$_.Name"} -whatif > or > Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup -Displayname > {"~$_.Name"} -whatif > > > Brandon Shell > --------------- > Blog: http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > J> I want to rename all my distribution groups display names to ahve a ~ > J> in front (just changing the display name to better organize our GAL). > J> Why does $_.Name come back null in this? > J> > J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" + > J> $_.Name) > J> > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: why is $_.Name null for this? If you want the opposite. This will tell you the groups that are failing (assuming there is actually an object) Get-DistributionGroup | ?{$_.Name -eq $null} I suspect your running into a bug with Get-DistributionGroup returning invalid data. Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject J> thanks for showing me the -whatif switch (just learned of it). J> However, it J> doesn't seem to tell me what it would do to the group, just the J> groups that J> it would ahve effected..not what it would ahve done to them. when I J> tried to J> run it agaist a specific group it changed the display name to J> "~$_.Name" J> here was the test line I tried: J> Get-DistributionGroup -identity DEPT-CAPE-IT | Set-DistributionGroup J> -Displayname {"~$_.Name"} -whatif J> "Brandon Shell [MVP]" wrote: J> Quote: Quote: >> Can you try this? >> >> Get-DistributionGroup | Set-DistributionGroup -Displayname >> {"~$_.Name"} -whatif >> or >> Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup >> -Displayname >> {"~$_.Name"} -whatif >> Brandon Shell >> --------------- >> Blog: http://www.bsonposh.com/ >> PSH Scripts Project: www.codeplex.com/psobject >> J> I want to rename all my distribution groups display names to ahve >> a ~ >> J> in front (just changing the display name to better organize our >> GAL). >> J> Why does $_.Name come back null in this? >> J> >> J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" + >> J> $_.Name) >> J> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: why is $_.Name null for this? I've run into this sort of problem with something being null that I expected to contain data.. each time I ahve to "cheat" and dump data to a csv then call it back in.. I had to do this one in two parts just like before: Get-DistributionGroup | export-csv test.csv -notype Import-Csv test.csv | foreach {Set-DistributionGroup -Identity $_.name -Displayname ("~" + $_.name).ToString()} all well.. someday I'll get good at powershell.. I really like it.. I'm just having a hard time getting the proper syntax "Brandon Shell [MVP]" wrote: Quote: > If you want the opposite. This will tell you the groups that are failing > (assuming there is actually an object) > > Get-DistributionGroup | ?{$_.Name -eq $null} > > I suspect your running into a bug with Get-DistributionGroup returning invalid > data. > > Brandon Shell > --------------- > Blog: http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > J> thanks for showing me the -whatif switch (just learned of it). > J> However, it > J> doesn't seem to tell me what it would do to the group, just the > J> groups that > J> it would ahve effected..not what it would ahve done to them. when I > J> tried to > J> run it agaist a specific group it changed the display name to > J> "~$_.Name" > J> here was the test line I tried: > J> Get-DistributionGroup -identity DEPT-CAPE-IT | Set-DistributionGroup > J> -Displayname {"~$_.Name"} -whatif > J> "Brandon Shell [MVP]" wrote: > J> Quote: Quote: > >> Can you try this? > >> > >> Get-DistributionGroup | Set-DistributionGroup -Displayname > >> {"~$_.Name"} -whatif > >> or > >> Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup > >> -Displayname > >> {"~$_.Name"} -whatif > >> Brandon Shell > >> --------------- > >> Blog: http://www.bsonposh.com/ > >> PSH Scripts Project: www.codeplex.com/psobject > >> J> I want to rename all my distribution groups display names to ahve > >> a ~ > >> J> in front (just changing the display name to better organize our > >> GAL). > >> J> Why does $_.Name come back null in this? > >> J> > >> J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" + > >> J> $_.Name) > >> J> > > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: why is $_.Name null for this? I don't understand your purpose. Why doesnt this work for you? (minus the -whatif) Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup -Displayname {"~$_.Name"} -whatif Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject J> I've run into this sort of problem with something being null that I J> expected to contain data.. each time I ahve to "cheat" and dump data J> to a csv then call it back in.. I had to do this one in two parts J> just like before: J> J> Get-DistributionGroup | export-csv test.csv -notype J> J> Import-Csv test.csv | foreach {Set-DistributionGroup -Identity J> $_.name -Displayname ("~" + $_.name).ToString()} J> J> all well.. someday I'll get good at powershell.. I really like it.. J> I'm just having a hard time getting the proper syntax J> J> "Brandon Shell [MVP]" wrote: J> Quote: Quote: >> If you want the opposite. This will tell you the groups that are >> failing (assuming there is actually an object) >> >> Get-DistributionGroup | ?{$_.Name -eq $null} >> >> I suspect your running into a bug with Get-DistributionGroup >> returning invalid data. >> >> Brandon Shell >> --------------- >> Blog: http://www.bsonposh.com/ >> PSH Scripts Project: www.codeplex.com/psobject >> J> thanks for showing me the -whatif switch (just learned of it). >> J> However, it >> J> doesn't seem to tell me what it would do to the group, just the >> J> groups that >> J> it would ahve effected..not what it would ahve done to them. when >> I >> J> tried to >> J> run it agaist a specific group it changed the display name to >> J> "~$_.Name" >> J> here was the test line I tried: >> J> Get-DistributionGroup -identity DEPT-CAPE-IT | >> Set-DistributionGroup >> J> -Displayname {"~$_.Name"} -whatif >> J> "Brandon Shell [MVP]" wrote: >> J> Quote: >>>> Can you try this? >>>> >>>> Get-DistributionGroup | Set-DistributionGroup -Displayname >>>> {"~$_.Name"} -whatif >>>> or >>>> Get-DistributionGroup | ?{$_.Name -ne $null} | >>>> Set-DistributionGroup >>>> -Displayname >>>> {"~$_.Name"} -whatif >>>> Brandon Shell >>>> --------------- >>>> Blog: http://www.bsonposh.com/ >>>> PSH Scripts Project: www.codeplex.com/psobject >>>> J> I want to rename all my distribution groups display names to >>>> ahve >>>> a ~ >>>> J> in front (just changing the display name to better organize our >>>> GAL). >>>> J> Why does $_.Name come back null in this? >>>> J> >>>> J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" >>>> + >>>> J> $_.Name) >>>> J> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: why is $_.Name null for this? when I ran that it renamed all ym distro lists to "$_.Name" "Brandon Shell [MVP]" wrote: Quote: > I don't understand your purpose. > > Why doesnt this work for you? (minus the -whatif) > Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup -Displayname > {"~$_.Name"} -whatif > > Brandon Shell > --------------- > Blog: http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > J> I've run into this sort of problem with something being null that I > J> expected to contain data.. each time I ahve to "cheat" and dump data > J> to a csv then call it back in.. I had to do this one in two parts > J> just like before: > J> > J> Get-DistributionGroup | export-csv test.csv -notype > J> > J> Import-Csv test.csv | foreach {Set-DistributionGroup -Identity > J> $_.name -Displayname ("~" + $_.name).ToString()} > J> > J> all well.. someday I'll get good at powershell.. I really like it.. > J> I'm just having a hard time getting the proper syntax > J> > J> "Brandon Shell [MVP]" wrote: > J> Quote: Quote: > >> If you want the opposite. This will tell you the groups that are > >> failing (assuming there is actually an object) > >> > >> Get-DistributionGroup | ?{$_.Name -eq $null} > >> > >> I suspect your running into a bug with Get-DistributionGroup > >> returning invalid data. > >> > >> Brandon Shell > >> --------------- > >> Blog: http://www.bsonposh.com/ > >> PSH Scripts Project: www.codeplex.com/psobject > >> J> thanks for showing me the -whatif switch (just learned of it). > >> J> However, it > >> J> doesn't seem to tell me what it would do to the group, just the > >> J> groups that > >> J> it would ahve effected..not what it would ahve done to them. when > >> I > >> J> tried to > >> J> run it agaist a specific group it changed the display name to > >> J> "~$_.Name" > >> J> here was the test line I tried: > >> J> Get-DistributionGroup -identity DEPT-CAPE-IT | > >> Set-DistributionGroup > >> J> -Displayname {"~$_.Name"} -whatif > >> J> "Brandon Shell [MVP]" wrote: > >> J> > >>>> Can you try this? > >>>> > >>>> Get-DistributionGroup | Set-DistributionGroup -Displayname > >>>> {"~$_.Name"} -whatif > >>>> or > >>>> Get-DistributionGroup | ?{$_.Name -ne $null} | > >>>> Set-DistributionGroup > >>>> -Displayname > >>>> {"~$_.Name"} -whatif > >>>> Brandon Shell > >>>> --------------- > >>>> Blog: http://www.bsonposh.com/ > >>>> PSH Scripts Project: www.codeplex.com/psobject > >>>> J> I want to rename all my distribution groups display names to > >>>> ahve > >>>> a ~ > >>>> J> in front (just changing the display name to better organize our > >>>> GAL). > >>>> J> Why does $_.Name come back null in this? > >>>> J> > >>>> J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" > >>>> + > >>>> J> $_.Name) > >>>> J> > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: why is $_.Name null for this? This bites everyone I believe that Brandon explained to me back last Sept when I was started to use Powershell; but alas I've forgotten the exact reason. Unfortunately even when you really know what your doing you still make this mistake within quotes you _MUST_ add an extra $() Get-DistributionGroup | ? {$_.Name -ne $null} | Set-DistributionGroup -Displayname ^^^^^ (here you do not) {"~$($_.Name)"} -whatif ^^^^^ (here you must) Between this and Powershell not screeming at you when you make a misspell a property i.e. 'hello'.lenght I'm not sure which is more anonying but I'm consistently doing both. "Jason" wrote: Quote: > when I ran that it renamed all ym distro lists to > "$_.Name" > > "Brandon Shell [MVP]" wrote: > Quote: > > I don't understand your purpose. > > > > Why doesnt this work for you? (minus the -whatif) > > Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup -Displayname > > {"~$_.Name"} -whatif > > > > Brandon Shell > > --------------- > > Blog: http://www.bsonposh.com/ > > PSH Scripts Project: www.codeplex.com/psobject > > > > J> I've run into this sort of problem with something being null that I > > J> expected to contain data.. each time I ahve to "cheat" and dump data > > J> to a csv then call it back in.. I had to do this one in two parts > > J> just like before: > > J> > > J> Get-DistributionGroup | export-csv test.csv -notype > > J> > > J> Import-Csv test.csv | foreach {Set-DistributionGroup -Identity > > J> $_.name -Displayname ("~" + $_.name).ToString()} > > J> > > J> all well.. someday I'll get good at powershell.. I really like it.. > > J> I'm just having a hard time getting the proper syntax > > J> > > J> "Brandon Shell [MVP]" wrote: > > J> Quote: > > >> If you want the opposite. This will tell you the groups that are > > >> failing (assuming there is actually an object) > > >> > > >> Get-DistributionGroup | ?{$_.Name -eq $null} > > >> > > >> I suspect your running into a bug with Get-DistributionGroup > > >> returning invalid data. > > >> > > >> Brandon Shell > > >> --------------- > > >> Blog: http://www.bsonposh.com/ > > >> PSH Scripts Project: www.codeplex.com/psobject > > >> J> thanks for showing me the -whatif switch (just learned of it). > > >> J> However, it > > >> J> doesn't seem to tell me what it would do to the group, just the > > >> J> groups that > > >> J> it would ahve effected..not what it would ahve done to them. when > > >> I > > >> J> tried to > > >> J> run it agaist a specific group it changed the display name to > > >> J> "~$_.Name" > > >> J> here was the test line I tried: > > >> J> Get-DistributionGroup -identity DEPT-CAPE-IT | > > >> Set-DistributionGroup > > >> J> -Displayname {"~$_.Name"} -whatif > > >> J> "Brandon Shell [MVP]" wrote: > > >> J> > > >>>> Can you try this? > > >>>> > > >>>> Get-DistributionGroup | Set-DistributionGroup -Displayname > > >>>> {"~$_.Name"} -whatif > > >>>> or > > >>>> Get-DistributionGroup | ?{$_.Name -ne $null} | > > >>>> Set-DistributionGroup > > >>>> -Displayname > > >>>> {"~$_.Name"} -whatif > > >>>> Brandon Shell > > >>>> --------------- > > >>>> Blog: http://www.bsonposh.com/ > > >>>> PSH Scripts Project: www.codeplex.com/psobject > > >>>> J> I want to rename all my distribution groups display names to > > >>>> ahve > > >>>> a ~ > > >>>> J> in front (just changing the display name to better organize our > > >>>> GAL). > > >>>> J> Why does $_.Name come back null in this? > > >>>> J> > > >>>> J> Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" > > >>>> + > > >>>> J> $_.Name) > > >>>> J> > > > > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: why is $_.Name null for this? That is correct... I completely missed the OP question. I was thinking about the object being $null... didn't even think about string expansion. Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject BL> This bites everyone I believe that Brandon explained to me back last BL> Sept when I was started to use Powershell; but alas I've forgotten BL> the exact reason. BL> BL> Unfortunately even when you really know what your doing you still BL> make this mistake BL> BL> within quotes you _MUST_ add an extra $() BL> BL> Get-DistributionGroup | ? {$_.Name -ne $null} | BL> Set-DistributionGroup BL> -Displayname BL> ^^^^^ BL> (here you do not) BL> {"~$($_.Name)"} -whatif BL> ^^^^^ BL> (here you must) BL> Between this and Powershell not screeming at you when you make a BL> misspell a property i.e. BL> BL> 'hello'.lenght BL> BL> I'm not sure which is more anonying but I'm consistently doing both. BL> BL> "Jason" wrote: BL> Quote: Quote: >> when I ran that it renamed all ym distro lists to "$_.Name" >> >> "Brandon Shell [MVP]" wrote: >> Quote: >>> I don't understand your purpose. >>> >>> Why doesnt this work for you? (minus the -whatif) >>> Get-DistributionGroup | ?{$_.Name -ne $null} | Set-DistributionGroup >>> -Displayname >>> {"~$_.Name"} -whatif >>> Brandon Shell >>> --------------- >>> Blog: http://www.bsonposh.com/ >>> PSH Scripts Project: www.codeplex.com/psobject >>> J> I've run into this sort of problem with something being null that >>> I >>> J> expected to contain data.. each time I ahve to "cheat" and dump >>> data >>> J> to a csv then call it back in.. I had to do this one in two >>> parts >>> J> just like before: >>> J> >>> J> Get-DistributionGroup | export-csv test.csv -notype >>> J> >>> J> Import-Csv test.csv | foreach {Set-DistributionGroup -Identity >>> J> $_.name -Displayname ("~" + $_.name).ToString()} >>> J> >>> J> all well.. someday I'll get good at powershell.. I really like >>> it.. >>> J> I'm just having a hard time getting the proper syntax >>> J> >>> J> "Brandon Shell [MVP]" wrote: >>> J> >>>>> If you want the opposite. This will tell you the groups that are >>>>> failing (assuming there is actually an object) >>>>> >>>>> Get-DistributionGroup | ?{$_.Name -eq $null} >>>>> >>>>> I suspect your running into a bug with Get-DistributionGroup >>>>> returning invalid data. >>>>> >>>>> Brandon Shell >>>>> --------------- >>>>> Blog: http://www.bsonposh.com/ >>>>> PSH Scripts Project: www.codeplex.com/psobject >>>>> J> thanks for showing me the -whatif switch (just learned of it). >>>>> J> However, it >>>>> J> doesn't seem to tell me what it would do to the group, just the >>>>> J> groups that >>>>> J> it would ahve effected..not what it would ahve done to them. >>>>> when >>>>> I >>>>> J> tried to >>>>> J> run it agaist a specific group it changed the display name to >>>>> J> "~$_.Name" >>>>> J> here was the test line I tried: >>>>> J> Get-DistributionGroup -identity DEPT-CAPE-IT | >>>>> Set-DistributionGroup >>>>> J> -Displayname {"~$_.Name"} -whatif >>>>> J> "Brandon Shell [MVP]" wrote: >>>>> J> >>>>>>> Can you try this? >>>>>>> >>>>>>> Get-DistributionGroup | Set-DistributionGroup -Displayname >>>>>>> {"~$_.Name"} -whatif >>>>>>> or >>>>>>> Get-DistributionGroup | ?{$_.Name -ne $null} | >>>>>>> Set-DistributionGroup >>>>>>> -Displayname >>>>>>> {"~$_.Name"} -whatif >>>>>>> Brandon Shell >>>>>>> --------------- >>>>>>> Blog: http://www.bsonposh.com/ >>>>>>> PSH Scripts Project: www.codeplex.com/psobject >>>>>>> J> I want to rename all my distribution groups display names to >>>>>>> ahve >>>>>>> a ~ >>>>>>> J> in front (just changing the display name to better organize >>>>>>> our >>>>>>> GAL). >>>>>>> J> Why does $_.Name come back null in this? >>>>>>> J> >>>>>>> J> Get-DistributionGroup | Set-DistributionGroup -Displayname >>>>>>> ("~" >>>>>>> + >>>>>>> J> $_.Name) >>>>>>> J> |
My System Specs![]() |
| | #10 (permalink) |
| | Re: why is $_.Name null for this? Use the foreach cmdlet to make the automatic variable $_ available, this should work: Get-DistributionGroup | foreach { Set-DistributionGroup $_ -DisplayName ("~"+$_.name)} ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I want to rename all my distribution groups display names to ahve a ~ > in front (just changing the display name to better organize our GAL). > Why does $_.Name come back null in this? > > Get-DistributionGroup | Set-DistributionGroup -Displayname ("~" + > $_.Name) > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Help with Null please | VB Script | |||
| [string]$a = $null; $a -eq $null; $a -eq "" | PowerShell | |||
| Why is this null? | PowerShell | |||
| Re: "Error: 'null' is null or not an object" when trying to view video | Vista performance & maintenance | |||
| Gotcha: $null to [string] IS NOT $null | PowerShell | |||