powershell scripting.

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 3 years and 1 month 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
DanielJohnson
Posts: 6
Last visit: Tue Feb 02, 2021 11:54 pm

powershell scripting.

Post by DanielJohnson »

Hello,

I am fairly new to powershell scripting. With that said, I have a script that creates a CNAME record in dns. The script runs fine when clicking the 'Run' button in Powershell Studio 2020. I added this script to a larger config script, and now the script fails. After doing some troubleshooting, I found that this section runs fine in PS 2020 if I highlight the create CNAME code and right click "Run Selection", but fails if I select "Run Selection in Console.
Any Idea what I am doing wrong?


Any guidance would be appreciated!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: powershell scripting.

Post by jvierra »

Hi Daniel

Your issues are4 all a result of lack of knowledge of the basics of PowerShell. This wilkl make everything including how to use PSS very difficult. I recommend starting with a simple book to get you started. The first four chapters of this free and excellent introductory book will get you on the right path. Also review the other items in teh Info Center and the video list as there is a very large amount of information designed to help noon-programmers get started with {PowerShell.

https://www.sapien.com/books_training/W ... werShell-4

Your question, as asked, does not have enough information to even begin to suggest an answer. The best suggestion I can make is to run the full script under the PSS debugger to see if your code is actually being called. Common misunderstandings of how code and PowerShell work lead to the situation you describe although the exact cause can be any of 100+ reasons.

Another thing to note is that you say the code fails without indicating what that means. How do you know it is failing?
This topic is 3 years and 1 month 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