Well there are lots of questions I have, so I figured that opening many thread might not be the solution.
To make it a simple rule for you - one thread for one issue you have with code you wrote by yourself.
Until now you did not post any line of code you have problems with.
In general: It is beyond the scope of this (or any) forum to teach you step by step how to write PowerShell scripts. We actually expect you to learn the very basic of PowerShell by yourself first.
Then if you have an issue with your code you should first try to solve it by yourself. Google it, search in forums like this or on MSFT or search StackOverflow. If you didn’t find a solution there you are very welcome to post your question here (or in any other forum) including the code you wrote along with the errors if there are some and an explanation of the environment if suitable. Then we will be happy to assist you and help you further.
If you use modules, scripts or code from other people and you have problems with it you should first ask the author for help. If you found a bug in their code they even will be happy about your finding I think.
Well, first of all, this thread was solely created for the purpose of being able to run the windows updates via a powershell script.
And the error I receive belongs to an excercise I’m doing in order to learn powershell. I never expected to learn it step by step here (as if anybody had the patience lol)
As expected, a few things are in germen because the book is, I can translate it if that helps other people understanding it better. Anyway, since using one thread for multiple issues isn’t allowed, I’d rather have this thread then be for the error message.
[1_Basiswissen/ErsteSchritte/LocalUser_Create.ps1]
PowerShell-Script
Lokales Benutzerkonto anlegen
(C) Robin da Silva Martins
Eingabewerte
$Name = “”
$Accountname = “”
$Description = “Powershell lernen und Kenntnisse erweitern”
$Password = “”
$Computer = “localhost”
“Anlegen des Benutzerskonto $Name auf $Computer”
Zugriff auf Container mit der COM-Bibliothek ''Active Directory Service Interface"
$Container = [ADSI] “WinNT://$Computer”
Benutzer anlegen
$objUser = $Container.Create(“user”, $Accountname)
$objUser.Put(“Fullname”, $Name)
$objUser.Put(“Description”, $Description)
Kennwort setzen
$objUser.SetPassword($Password)
Änderung speichern
$objUser.SetInfo()
“Benutzer angelegt: $Name auf $Computer”
Error message:
It looks like you are trying to set an empty password, which is pretty much verboten on any secure operating system.
There are some German forums dedicated to PowerShell scripting. You might post your questions there. Sometimes it is easier to be able to ask your questions in your native language. ![]()
If you’re interested:
or this:
https://social.technet.microsoft.com/Forums/de-DE/home?forum=powershell_de
Regardless of that - again, please, when you post code or error messages format it as code using the preformatted text button ( </> ).
Thanks in advance.
It seems like you have some comments in your script without actually making them proper comments with the “#” sign. PowerShell tries to interpret everything as code what’s not after a “#” sign on the same line or beween “<#” and “#>”.
So when your script actually starts with
[1_Basiswissen/ErsteSchritte/LocalUser_Create.ps1]
it cannot work as this is no PowerShell code.
So you either remove everything what’s “not code” from your script or you make each single line what’s not code a comment by adding a “#” at the beginning of the line.
First of all, thanks for the feedback so far.
I removed the password on purpose, so you shouldn’t pay too much attention to that.
This was the first forum I found regarding PowerShell, so I took it.
The weird thing about all this is that the entire code was already given within the book I received, so all I did was write it down. So the code from the book was already wrong to begin with? Oo
And thank you for the link to a german forum, saves me the trouble of having to translate my written code.
Probaby not. But when you accidently treat normal text like code and try to run it it will not work. ![]()
