none
Export-CSV Not working for a user RRS feed

  • Question

  • Hi Guys,

    Here's a good one for you. I have a client who is trying to run the script Get-ScheduledTasks.ps1 with the option to export-csv. So he's running .\get-scheduledTask.ps1 | Export-CSV C:\schedtask\schedtask.csv The script runs just fine but doesn't output to the csv it just displays the output in the ISE console window. It does this if he's logged onto his laptop, the server itself, as him or as another local account.

    Here's the weird thing I can run the script just fine on both my laptop, and the server, logged on as myself or as the same local user he tried to run the script on and it works just fine. There are no errors when he runs the script it just refuses to output to the CSV file for him, no matter who he's logged on as.

    If anyone has come across this before and knows why.

    TIA

    Thursday, March 13, 2014 2:29 PM

Answers

  • Hi,

    It sounds like you have a grasp on how to run PowerShell scripts in general. You might ask the author of the script about the problem. This is really a general peer-to-peer scripting question and answer forum. It's not really a technical support forum for scripts posted in the gallery.

    I believe jrv's statements are tongue-in-cheek, as it were. What he was trying to say is that if the script works on one computer (or environment) but not another computer (or environment), then there is something with the computer (or environment) that is causing the problem. As I said, we don't have the resources to chase this down for you because this isn't a technical support forum but rather a user-to-user scripting questions forum. You don't really have a scripting question but rather a support question for a specific script that someone wrote.

    I would suggest also trying a different script; perhaps this one?

    Windows IT Pro: How-To: Use PowerShell to Report on Scheduled Tasks


    -- Bill Stewart [Bill_Stewart]

    Thursday, March 13, 2014 5:28 PM
    Moderator

All replies

  • Sounds like you need to call the repairman.  This is not a scripting issue.  You have already proven that the script works.

    Of course you are not telling us what is in "Get-ScheduledTask.ps1".  Perhaps it has something that detects that one user and wends the output to the wrong place.  Sort of a joke script.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 2:45 PM
  • I would also ask how you can run the same script as you co-worker if the script is started like this:

    .\Get-ScheduledTasks.ps1

    Are you all using the same account. You must be using different copies of the script file or you are not telling us the whole story.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 2:48 PM
  • Script comes from here. and it's not a joke script.
     http://gallery.technet.microsoft.com/scriptcenter/6dd4289b-5407-45e2-9093-8811e9a20b89 

    "I would also ask how you can run the same script as you co-worker if the script is started like this:

    .\Get-ScheduledTasks.ps1" Answer: From  ISE.

    "Are you all using the same account. You must be using different copies of the script file or you are not telling us the whole story." Same script from  the same directory and using the same execution process. We logged on as the same local user from different remote desktop sessions as part of the troubleshooting process.

    Thursday, March 13, 2014 2:57 PM
  • So you are both logging in as the same user account and running the script.  It works when you log in but not when your friend logs in.

    The two of you have to be doing different things or you are not logging in as the same user.  If you are dotting the script then run it with an explicit folder name.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 3:03 PM
  • When I asked from  where I meant "from what folder" not "from what program".

    Two accounts will not have the same default directory for PowerShell.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 3:05 PM
  • I have watched him run the script, I have told him what to type. We ARE logged on as the same user, and we are running the script in the same way with the same wording from the same directory. That's why I asked the forums if anyone has come across this before.
    Thursday, March 13, 2014 3:06 PM
  • If you carefully read the script you posted it clearly states that it outputs nothing.

    Somewhere you are doing two different things.

    I suggest getting an analyst to follow both of you around and discover what you are doing.  One of you is a bit deluded about what is happening.

    Prepare yourself for a big embarrassment.

    Here is what it says in the directions for the script you posted the link for:

     .OUTPUTS 
            Nothing 
     There is no output to send to a CSV.

    The internal code does the following:

    $tasks = & schtasks /query /$ComputerName /fo csv /| ConvertFrom-Csv 

    See - no output.

    THen it does this:

     Send-MailMessage -Body $TasksInError -BodyAsHtml -From donotreply@mydomain.com -SmtpServer mysmtpserver.mydomain.com -Subject "Scheduled Tasks Report - $ComputerName" -To myaddress@mydomain.com  

    See - still no output.

    That is all there is in  your script.  Go back and retest and pay close attention to what you are doing.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 3:12 PM
  • I have watched him run the script, I have told him what to type. We ARE logged on as the same user, and we are running the script in the same way with the same wording from the same directory. That's why I asked the forums if anyone has come across this before.

    I deal with delusional Admins everyday.  I believe all Admins should be required to take Prozac.  Mostly it is overwork or insane bosses.  In other cases it is just too much partying the night before.

    Admins call me early in the morning screaming that the world is ending because their files are all gone.  After a little psychoanalyses we discover that they remapped their home drive to test something on Friday and forgot about it.

    Rule of Admin fun:  When something is weird it means you need to slow down and look more closely.  IT is your brain that is weird 99% of the time.  Stop being superstitious.  The "ghost in  the machine" was discounted long ago by Einstein.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 3:18 PM
  • Apologies this is the script we're running. I just did a google search for the script name and it returned a couple of links.

    http://gallery.technet.microsoft.com/scriptcenter/Get-Scheduled-tasks-from-3a377294

    We've already been through the process of getting another tech to sanity check it.

    Thursday, March 13, 2014 3:27 PM
  • Apologies this is the script we're running. I just did a google search for the script name and it returned a couple of links.

    http://gallery.technet.microsoft.com/scriptcenter/Get-Scheduled-tasks-from-3a377294

    We've already been through the process of getting another tech to sanity check it.

    So inaccuracy pile up.

    It does not explain how two people can type identical lines at the exact same prompt and get different results. (Need Prozac?)

    Think about what you are asking.  Either you are leaving out critical information or you are missing something when you test or you have a bad supply of Prozac.  Your choice.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 3:44 PM
  • Apologies this is the script we're running. I just did a google search for the script name and it returned a couple of links.

    http://gallery.technet.microsoft.com/scriptcenter/Get-Scheduled-tasks-from-3a377294

    We've already been through the process of getting another tech to sanity check it.

    So inaccuracy pile up.

    It does not explain how two people can type identical lines at the exact same prompt and get different results. (Need Prozac?)

    Think about what you are asking.  Either you are leaving out critical information or you are missing something when you test or you have a bad supply of Prozac.  Your choice.


    ¯\_(ツ)_/¯

    You are insulting and unhelpful again JRV. I do not need anti-depressants, I was asking if someone had any ideas as to why this was happening. But in your, usual insulting manner, you've done nothing but make assumptions and act superior. If you've nothing useful to add, go away. BTW it sounds more likely that you're the one with the delusional tenancies.
    Thursday, March 13, 2014 3:50 PM
  • What you are saying does not make any sense.  I am teasing you because you have blinded yourself to the problems that your question implies.

    If two people sit at the same console and type identical lines and get totally different output using the exact code youhave linked then you aare not seeing something because this is impossible.  You have to be missing something.

    If you cannot ssee that your request is impossible to use to help solve your problem then you need to think about it more carefully.

    If someone came to you with the same issues you would likely react in a similar way.

    What you are asking is not possible unless the information you are delivering in missing something which I am sure it is ,  We cannot see what you are typing.  It is up to you to figure this out. 

    You have already delivered three different scenarios.  It is hard to know what else you may be mistaken about.

    Take a break for a bit and lighten up.  Being to immersed in a problem will make you miss things.  When you come back later you will likely see your mistake.

    When you finally figure this out you will realize that maybe Prozac might help ;)


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 4:03 PM
  • What you are saying does not make any sense.  I am teasing you because you have blinded yourself to the problems that your question implies.

    If two people sit at the same console and type identical lines and get totally different output using the exact code youhave linked then you aare not seeing something because this is impossible.  You have to be missing something.

    If you cannot ssee that your request is impossible to use to help solve your problem then you need to think about it more carefully.

    If someone came to you with the same issues you would likely react in a similar way.

    What you are asking is not possible unless the information you are delivering in missing something which I am sure it is ,  We cannot see what you are typing.  It is up to you to figure this out. 

    You have already delivered three different scenarios.  It is hard to know what else you may be mistaken about.

    Take a break for a bit and lighten up.  Being to immersed in a problem will make you miss things.  When you come back later you will likely see your mistake.

    When you finally figure this out you will realize that maybe Prozac might help ;)


    ¯\_(ツ)_/¯

    Insulting again. You are insulting JRV. You need to learn a little politeness. Also stop insinuating that I need anti-depressants, I don't! You sound more like a candidate for the said drug.
    Thursday, March 13, 2014 4:08 PM
  • Hi,

    As noted, this is not a scripting issue. If the command you are typing works on one computer but not another, then there is something different between the two computers or environments that causes the different results. But also it's not possible for us to troubleshoot because we don't have access to your network nor can we see your screen.

    Sorry but it sounds like you're on your own on this one.


    -- Bill Stewart [Bill_Stewart]

    Thursday, March 13, 2014 4:36 PM
    Moderator
  • Good afternoon Bill,

    As I have mentioned, the problem not only appears on different laptops, but also when connecting to the remote desktop console via the same laptops. As such

    User1: Logged onto laptop1 with his account, runs the script with the parameter added to connect via network to the server with the option to output to the csv file, and it doesn't.

    User2: Logged onto a different laptop, laptop2, with their own account does the same, with the same script, it works.

    User1: Logs onto the server via remote desktop as himself and runs the script, which has been copied to the servers D drive in a folder called tools. Same result; no output.

    User2: Logs onto the same server via remote desktop and runs the same script from the same directory on the D drive. Output is successful.

    User1: logs onto server as a local admin account via remote desktop from laptop1, runs the script located in the D drive tools directory. No output.

    User2: Logs onto the server as the same local admin account via remote desktop from laptop2, runs the script located in the D drive tools directory. Output successful.

    I appreciate this is an odd one, we have checked and rechecked this and even had others sanity check it. Now if nobody has come across this before then so be it. We'll just mark it down as another one of life's mysteries and work around it. I just thought I'd ask if someone had seen this type of behavior before.

    But I don't feel it's necessary for JRV to make insulting comments and suggest that I need to start taking Prozac. This is the second time he's behaved in such a fashion and it is unacceptable.

    Many thanks.

    Thursday, March 13, 2014 4:53 PM
  • What was insulting.  I jokingly made a reference to how overworked and underappreciated Admins are and that they should be allowed to use Prozac.  It was a satirical statement.

    In the end this is not a scripting issue.  I said that a long time ago.   Now go take your Prozac and try to get a fix on what is wrong.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 5:23 PM
  • Hi,

    It sounds like you have a grasp on how to run PowerShell scripts in general. You might ask the author of the script about the problem. This is really a general peer-to-peer scripting question and answer forum. It's not really a technical support forum for scripts posted in the gallery.

    I believe jrv's statements are tongue-in-cheek, as it were. What he was trying to say is that if the script works on one computer (or environment) but not another computer (or environment), then there is something with the computer (or environment) that is causing the problem. As I said, we don't have the resources to chase this down for you because this isn't a technical support forum but rather a user-to-user scripting questions forum. You don't really have a scripting question but rather a support question for a specific script that someone wrote.

    I would suggest also trying a different script; perhaps this one?

    Windows IT Pro: How-To: Use PowerShell to Report on Scheduled Tasks


    -- Bill Stewart [Bill_Stewart]

    Thursday, March 13, 2014 5:28 PM
    Moderator
  • That was not your comment at all, i.e. "I deal with delusional Admins everyday" you don't class that comment as insulting? Another example - " (Need Prozac?)" and another "Either you are leaving out critical information or you are missing something when you test or you have a bad supply of Prozac.  Your choice." And again - "When you finally figure this out you will realize that maybe Prozac might help ;)"If you can't see that these comments are unacceptable and unprofessional then you need to think closely about your role online.

    You need to develop a little respect and professionalism JRV. If you can't see where you're going wrong with your comments may a recommend some counseling or customer service training.
    Thursday, March 13, 2014 5:39 PM
  • Bill if you really believe his comments are acceptable, you need to think about your position as a Moderator on this forum.
    Thursday, March 13, 2014 5:40 PM
  • jrv: You might consider refraining from further comments since the user is offended.

    wynn1964: Sorry you were offended. Sometimes jrv's brand of humor can come off as abrasive.


    -- Bill Stewart [Bill_Stewart]

    Thursday, March 13, 2014 5:51 PM
    Moderator
  • Too many people with no sense of humor.  They are too busy demanding things to have fun.

    Funny or not. There is no solution to this dilemma without the OP taking a closer look at what he is posting and what is really happening.  The clues are all here but, because we cannot see what Is really being done it is up to the OP to figure it out.

    I am sorry if the OP has an issue with Prozac.  Half of the world takes it.  I guess that is why everyone is so happy all of the time.

    I apologize if my words were taken seriously. I assure you I have nothing against the delusional Admins I deal with. Most of them would also consider that they are delusional on Monday mornings at least.  It is a very big battlefield in IT and the Admins take the brunt of it.  I support a bunch of Admins and they are very much used to my humor which was mostly borrowed from them.  The call me names all of the time.  I get picked on when I don't have an answer within 5 seconds.  They ask me if I am getting stupid and why can't I answer a simple question.  They do this because I usually answer them almost before they finish the question.

    Again - IT is a battlefield.  You have to get loose somehow or really become crazy.  There are days when I am on the phone for 12 or more hours.  Humor can save the day after the fir4st 8.


    ¯\_(ツ)_/¯

    Thursday, March 13, 2014 6:21 PM