Change Computer Description

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
DuckieTom
Posts: 3
Last visit: Sat Feb 10, 2018 10:54 am

Change Computer Description

Post by DuckieTom »

Hi,
The script below works on Windows PowerShell but doesn't work on PowerShell Studio 2017. I kept getting an error and I don't know what it means.
I've been trying to find a workaround for the last 2 days and I am stuck. What I am trying to do is have the script identify my computer and update the computer description to "SAMPLE DESCRIPTION" ...Can I please get some help?

Duckie

---Script---
$OSValues = Get-WmiObject -class Win32_OperatingSystem -computername "DUCKIE"
$OSValues.Description = "SAMPLE DESCRIPTION"
$OSValues.put()

---Error---
ERROR: Exception calling "Put" with "0" argument(s): "Access denied "
Description Updater.ps1 (18, 1): ERROR: At Line: 18 char: 1
ERROR: + $OSValues.put()
ERROR: + ~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
ERROR: + FullyQualifiedErrorId : DotNetMethodException
ERROR:

*** PowerShell Script finished. ***
>> Execution time: < 1 second
>> Script Ended
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Change Computer Description

Post by jvierra »

You have to run elevated to write to WMI. That is what "access denied" means.
User avatar
DuckieTom
Posts: 3
Last visit: Sat Feb 10, 2018 10:54 am

Re: Change Computer Description

Post by DuckieTom »

How do I run elevated?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Change Computer Description

Post by jvierra »

PSS_elevated.png
PSS_elevated.png (15.96 KiB) Viewed 2575 times
User avatar
DuckieTom
Posts: 3
Last visit: Sat Feb 10, 2018 10:54 am

Re: Change Computer Description

Post by DuckieTom »

Thank you!!! :D
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked