If I run this by itself it works fine and returns a list of servers, but when I have it followed by the rest of the code that starts with "$Remote Server = Read-Host "Enter server name to log users off of: " it doesnât list the servers, it just promprts for the server name and then continues with the rest of the code on down. I canât figure out why it doesnât show the list of servers first.
Hmmm ⌠call me picky but Get-ADUser does sound as it should not show servers at all.
Have you tried forcing the output with
Since you seem to list the possible options with a command before this one why donât you use an Out-GridView and let the user select the server with the mouse? That might even reduce errors because it avoids typos.
Calls the function Get-ADUser and it uses the output from the Get-ADUser SXDSH1 and lists all instances of that user being locked out the day before or the day of.
Honestly Iâm pretty darn new at PowerShell and just trying to piece this all together.
If I donât follow that line with more code it outputs this:
Why are all PowerShell newbies so stubborn? Whatâs so hard to share what youâve tried?
You want the output of a command shown to your console host but it doesnât. I suggested to try to use Out-Host to force the output to be shown on the console host.
I debated for a bit commenting on this. I felt ultimately there were a couple things that needed to be said regarding the communication here and as a mod I felt it was important enough to address. My aim isnât to call anyone out but to comment and provide some guiding principles. My intent is to show messages can be received in different ways by folks. Communication is difficult and forums like this, things can be lost to really take away from the goal.
Sarcasm doesnât really come through in all contexts of written prose. Thereâs certainly a time and place for it, but I donât think itâs here, in a PowerShell online forum. As to why, it does not add value to these types of conversations. Additionally, I think ways of declaring sarcasm can have multiple meanings. I think itâs an assumption to say a winky face = sarcasm, as it could mean different things to different people, and it also depends on the context of the message. I think this clouds any message and only adds to the confusion of communication.
I do also want to mention the response did not come off as sarcastic to me. I did look at each version of the post to make sure the message wasnât change from OP to ensure I would not read it differently. When I read the response, it read more like a misunderstanding of what the code did, maybe not seeing the thing it was being piped too at first glance, and it came off as âobviously Get-ADUser doesnât return computer objects, look at what the cmdlet name saysâ. I donât see what value sarcasm adds to this or why it would have been used. Just a reminder that regardless of intent, messages are interpreted by the people who are receiving it. Sometimes, asking for clarification, giving folks the benefit of the doubt, and even a simple apology goes a long way. We canât always know if someone would read that as sarcastic or not given the context, so itâs better to avoid in this context.
Itâs possible I misinterpreted this but when provided some things to try, I would avoid saying âitâs above my pay gradeâ. I would also avoid stating âI tried everythingâ then ask for how to implement it, and not share any of the code that you tried as a follow up. if it is above your paygrade, then you have someone else who is managing the code at your company, and you should start there. Itâs highly unlikely youâve tried âeverythingâ. Perhaps it might be helpful to know why we are asking for it. Simply put, we need to know what you tried to help you. We arenât here to write code for folks, though occasionally people are nice enough to do that. In order to get help, you do need to provide what you tried specifically. Iâm pointing this out as this was stated in reference to Out-Host, and simply saying âIâm a noviceâ doesnât help folks who do genuinely wish to help, but we certainly canât translate what âtried everything meansâ. In general folks who help on forums often get roped into helping a bit more than they should. When someone says âI tried everythingâ but doesnât share or says something like above my paygrade, it comes off as youâre not willing to put in the effort, so youâre asking someone else to do that to âfix itâ for you. While it occasionally happens, that isnât what these forums are for and thatâs not the expectation of anyone responding to a thread. Iâm sure it wasnât your intention to come off this way and from your perspective youâre thinking itâs probably something quick to write but weâre really about helping others learn and sometimes that means writing some code, failing, and coming back with â I tried to add this code here, and itâs erroring with this message. I tried to address the error like this, but I have not been successful, what else can I do to accomplish X task? Itâs going to be much easier to assist you, and furthermore, itâs clear youâre putting in the effort to solve your problems by writing code and it might just be that something needs slightly tweaked. I hope that makes sense.
Again, I am not trying to hurt anyoneâs feelings or call anyone out, I just want to take a moment to share some things and hopefully we can all grow a bit from it.