header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Error with WMI
Last Post 27 May 2008 08:20 PM by DonJ. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
jdelatorreUser is Offline
New Member
New Member
Posts:18
Avatar

--
27 May 2008 07:34 PM  

I cant seem to find why I get this error, as this property of Win32_logicaldisk is read/write according to MSDN Docs.

VolumeName
Data type: string
Access type: Read/write

Volume name of the logical disk.

Constraints: Maximum 32 characters.

 

 

this code errors on my XP and Vista box

 

$d = gwmi win32_logicaldisk

$d[1].volumename = "My C Drive"

$d[1].psbase.put()

 

it errors with

 

Exception calling "Put" with "0" argument(s): ""

 

Any help would be appreciated. 

 

Joel D.
DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134
Avatar

--
27 May 2008 07:37 PM  

Generally, you don't try to change the name of the property itself. You call Put() with the name of the property you want to change, and the new value.

[edit] Correction, sorry, I was thinking ADSI. That should work - is this a remote system? What version of Windows?

- Don Jones
www.ConcentratedTech.com
Subscribe (RSS) or visit for weekly PowerShell tips and lessons
jdelatorreUser is Offline
New Member
New Member
Posts:18
Avatar

--
27 May 2008 08:05 PM  
Thanks for the quick response.
Interesting because that code is pretty much verbatim from Bruce Payette's book.

Maybe you could provide an example of how you would use the put method don?

Joel D.
DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134
Avatar

--
27 May 2008 08:20 PM  
Actually, I wasn't reading your syntax correctly :).

This worked on my system:

$disks = gwmi win32_logicaldisk
$disk = $disks[1] # This is my C: drive
$disk.volumename = "TEST"
$disk.put()

This is on a Win2008 system, against the local system. Things might behave differently against a remote system or against a different operating system version.
- Don Jones
www.ConcentratedTech.com
Subscribe (RSS) or visit for weekly PowerShell tips and lessons
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer