Creating scheduled task to run powershell script

Hi all,
been following this guide on how to create scheduled task to run a .ps1 script:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx
When I manually run this task,in the history it says success, but it doesnt work.
The script should create a report and send me an e-mail.It works fine if i run it manually in Windows powershell or Powershell ISE.
I cannot see that a new report have been created either.
Anything im missing here?
Been using same account to run it manually and the one using in task scheduler.
thanks!
Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work

Hi all,
been following this guide on how to create scheduled task to run a .ps1 script:
http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx
When I manually run this task,in the history it says success, but it doesnt work.
Try executing the same command in cmd line, do you get a different result? or does that work as well?

Similar Messages

  • Running powershell script with customer parameters as a scheduled task

    tfl wrote:I guess I don't get why you are wanting thisMy regular tasks run,. and take data from data files. Want your batch to get processed today? Then add it to the queue file by 5:00 PM.. The task runs at 5:01 and works with whatever data is available. And if the file is empty, nothing happens each night. If you want to pass parameters like this, then why bother with a scheduled task? You'd need to remove the old one and add the new one each time. Which is extra work and complexity, especially if the task at hand is in any way 'dangerous' if run twice with the same data (ie you forget to change the task or remove it).I'm using a scheduled task to trigger the script, I'm using the "on event" trigger and then calling the script as an action. The method I was using before (calling via a bat file with the event Id hard coded into that"...

    Hi all,Having one of those hair pulling issues where something should work but for some reason its blindly refusing not to!I've created this script that is a bit of an extension to the email on eventID for task scheduled. It basically pulls out the various information from the actual event and fires off an email to our alerting team to investigate etc.That all works great, but what I'm now trying to do is get it to accept a custom parameter so the actual event ID its looking for doesn't have to be hard coded and can be passed to it via the commandline etc. I've got it all setup and work great but for the life of me can't get it to work correctly when set as a scheduled task. This is what the command basically looks like:powershell -executionpolicy bypass -command "& 'pathtofile\script.ps1' -evtid 8004"The latter part is the customer...
    This topic first appeared in the Spiceworks Community

  • Run Powershell Script task sequence

    Hi,
    Anyone have good documentation on how to use the Run PowerShell Script task sequence ?
    Thanks

    If you are just interested in running a powershell command without creating a package, you can do this with the the Command line step by using this format in the command line:
    PowerShell -ExecutionPolicy bypass -Command "& {your powershell commands}"
    Here is an example of a multiline command to increase the agents cache size. Notice the ";"'s which are used to delineate a new line.
    PowerShell -ExecutionPolicy bypass -Command "& {$UIResourceM gr = New-Object -ComObject UIResource.UIResourceMgr;$Cache = $UIResourceMgr.GetC acheInfo();$Cache.TotalSize = "20480"}"

  • Passing parameters with spaces to SCCM Run PowerShell Script task

    I am working on an OS deployment task sequence in SCCM 2012 R2 with several Run PowerShell Script tasks.  Most of them run fine, but I am having trouble with the one I need to pass parameters to.
    The parameters I need to pass are:
    -ComputerOU "ou=All Workstations,dc=contoso,dc=com" -GroupDN "cn=Group1,ou=All Groups,dc=contoso,dc=com"
    I have that line (with actual DNs) entered in Parameters of the task.
    But when the script runs on the target machine, the values of the parameters in the script are truncated at the spaces.  $ComputerOU is set to "ou=All" and $GroupDN is set to "cn=Group1,ou=all"
    What syntax should I be using the Parameters field of the Task in order to properly pass PowerShell parameter string values that include spaces?
    Tim Curwick
    MadWithPowerShell.com

    Thank you, TC, but I am not calling the parameters from within PowerShell.
    The parameters are in the settings of a task sequence task to be used by the task to launch a script.  The syntax I am using would be correct for use within PowerShell or from a command line or batch script, but SCCM appears to be doing some parsing
    before or while it is passing them to the script, possibly dropping the quotes which causes mishandling of the spaces in the string values.
    Historically, it is always challenging to give one application parameters to pass to another application, and the required syntax can get quite tricky when the two application handle quotes or spaces differently, or when the parent application wants to parse
    something intended to be passed on as is to the child application.
    I'm sure someone has already figured out what the syntax needs to be for doing this with an SCCM 'Run PowerShell Script" task, it's just one of those issues that is hard to Google effectively.
    Any other ideas?
    Tim Curwick
    MadWithPowerShell.com

  • Server 2012 Scheduled tasks not running after DST

    Since the DST change this weekend the weekly scheduled tasks on our 2012 standard server are not running.  The schedule show the correct next run time, but the task never runs.  The server correctly adjusted for the DST changes (We are in CST in
    the US) and if you look in the date time it notified us that the clock was set forward.
    Any ideas?

    Hi Mark,
    Before going further, would you please let me confirm whether only weekly scheduled tasks t run? In other words,
    did some daily scheduled tasks run smoothly?
    Based on current situation, please create a new weekly
    scheduled task and check if encounters the same issue.
    If this issue still persists. Please let me confirm if you make scheduled task run some commands or a script,
    or others I misunderstand. For an example, if run a script, please directly run it in the Windows Server 2012 Standard and check if there any issue occurred.
    Meanwhile, please open Task Scheduler, select this problematic weekly scheduled task, click General tab. Please
    check which user account was used to run this task. And please check Run with highest privileges, then check if can solve this issue.
    In addition, please check History tab in task Properties. Please pay attention on the time-point when the weekly
    scheduled task should be ran, and check if you can find some events at that time-point. It may help us to go further analysis.
    By the way, there is a similar thread. Please refer to.
    Certain scheduled tasks do not run anymore after DST change
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/47483baf-e7af-4bff-9db4-9c3d0ead2b41/certain-scheduled-tasks-do-not-run-anymore-after-dst-change?forum=winserver8gen
    Hope this helps.
    Best regards,
    Justin Gu

  • Schedule tasks to run on wake up?

    Is it possible to schedule tasks to run when a Mac wakes up (preferably Terminal/UNIX)?
    I want to run a script when I open my laptop. Is that possible without installing further software?

    You could use System Preferences -> Energy Saver -> Schedule  to wake up the Mac (or at least try), then if you can have your tasks run in the background, you might be able to either use a repeating Calendar entry that runs an app, Applescript, or Automator app, or use a launchd.plist (launchd is non-trivial, but effective).
    The key is to have tasks that do not need to be actually logged in at the time.  That is to say, they do not need a GUI up and running.
    Not sure that Dropbox works without being logged in, but there may be other ways to sync things between Macs without using Dropbox.  Maybe something like bittorrentsync (I've only heard about it, but have not played with it).
    As Chris CA suggests, so not shutdown your Macs, but maybe just sleep them with your account already logged in.  Then when the scheduler wakes them you are already logged in.  Then when the tasks you need to run complete, you can let the normal idle system sleep interval put them back to sleep (be sure to set the sleep interval to a long enough period to allow your tasks to complete).

  • Scheduled Tasks wont run

    I had recently upgarded to CF8 from CF7.
    After the upgrade non of my Scheduled Tasks are running.
    Even when i trigger the tasks manually from CFAdmin I get the response "This scheduled task was completed successfully."
    But nothing really runs. My application is using Integrated Windows Authentication and the schedulled tasks were running fine with CF7.
    Now when i switch off the Windows authentication, the scheduled tasks are working fine.
    Could you please tell me why my Scheduled Tasks are not running when i turn on Windows authenticaton, where as it was working perfectly with CF7.

    ColdFusion schedule tasks CAN NOT run under windows integrated authentication.  ColdFusion is not a windows product, it does not pass the NTML headers with requests.  You have to turn off windows integrated authentication for any resource you would like to run as a schedule task.  Helpfully, you can set that permssion to individual files and|or folders so you do not need to turn it off for the entire site.
    I don't know why this would change after an upgrade, unless you built a new CF8 server with a newly built IIS as well.

  • Issue with running powershell script in pssessions

    Hi Everyone,
    I am trying to run powershell script from remote machine using below commands
    C:\Users\user>"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
    -command "$s= New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri
    http://Exchservername/PowerShell/ -Authentication Kerberos ; Import-PSsession $s; "C:\Failback.ps1"
    and Below is the failback.ps1.
    $mbxs = Get-MailboxDatabase | Sort Name
    ForEach($mbx in $mbxs)
    $MBdb=$mbx.Name $ServerHosting=$mbx.Server.Name
    if($mbx.activationPreference.value -eq 1)
    If ($ServerHosting -ne $ActivationPreference.Key.Name) 
    Move-ActiveMailboxDatabase $MBdb -ActivateOnServer $ActivationPreference.Key.Name -confirm:$False 
    Below is what i am getting.

    What is your question?  Are you pointing out the yellow text?  This is normal, and appears every time EMS is opened.
    I should also point out that Microsoft provides a script to re-balance databases, if that's what you're trying to accomplish:
    You can use the RedistributeActiveDatabases.ps1 script to balance the active mailbox databases copies across a DAG. This script moves databases between their copies in an attempt to have an equal number of mounted databases on each server in DAG. If required,
    the script also attempts to balance active databases across sites.
    https://technet.microsoft.com/en-us/library/dd335158(v=exchg.141).aspx
    Mike Crowley | MVP
    My Blog --
    Baseline Technologies

  • How can I setup a scheduled task to run a Powershell Script delivered as a Group Policy Preference

    I have a Powershell script I want to run only once when a user logs onto their system. This script would move all the PST files from the Local drive and the Home drive to a folder location within the users profile. I wanted to run this as a Windows 7 Scheduled Task using Group Policy Preferences. How can I get this to happen short of a logon script? I have updated all the machines to WMF 4.0 so could I use a Scheduled Job instead? I wanted to run the script as the logon user but elevated.#Start Outlook and Disconnect attached PST files.
    $Outlook = New-Object -ComObject Outlook.Application
    $namespace = $outlook.getnamespace("MAPI")
    $folder = $namespace.GetDefaultFolder("olFolderInbox")
    $explorer = $folder.GetExplorer()
    $explorer.Display()
    $myArray= @()
    $outlook.Session.Stores | where{ ($_.FilePath -like'*.PST') } | foreach{[array]$myArray+= $_.FilePath}
    for
    ($x=0;$x-le$myArray.length-1;$x++)
    $PSTPath= $myArray[$x]
    $PST= $namespace.Stores | ?{$_.FilePath -like$PSTPath}
    $PSTRoot= $PST.GetRootFolder() #Get Root Folder name of PST
    $PSTFolder= $Namespace.Folders.Item($PSTRoot.Name) #Bind to PST for disconnection
    $Namespace.GetType().InvokeMember('RemoveStore',[System.Reflection.BindingFlags]::InvokeMethod,$null,$Namespace,($PSTFolder)) #Disconnect .PST
    #Move All PST files to the default location while deleting the PST files from their original location.
    $SourceList = ("$env:SystemDrive", "$env:HOMEDRIVE")
    $Destination = ("$env:USERPROFILE\MyOutlookFiles")
    (Get-ChildItem -Path $SourceList -Recurse -Filter *.PST) | Move-Item -Destination $Destination
    #Attach all PST files from the default location.
    Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
    $outlook = new-object -comobject outlook.application
    $namespace = $outlook.GetNameSpace("MAPI")
    dir “$env:USERPROFILE\MyOutlookFiles\*.pst” | % { $namespace.AddStore($_.FullName) }

    Mike,
    I do not understand what appears to be a regular expression above. I did add the PowerShell script to the HKCU RunOnce Key as suggested.
    Windows Registry Editor Version 5.00
    C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -sta -WindowStyle Hidden -ExecutionPolicy RemoteSigned -File "C:\scripts\Windows PowerShell\Move-PST.ps1"
     I'm delivering this using Group Policy Preferences. It seems to fail or time out when run because the behavior is different if I run the script from within the PowerShell IDE. I added the parameters to the script and will try it again in the morning.

  • Run Powershell script from Scheduled Task as "NT Authority \ SYSTEM"

    Hello, dear Colleagues.
    Cannot make Powershell script from Scheduled Task as "NT Authority \ System"
    Action: Start a program - 
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "C:\script.ps1"
    The matter is that script is working, moreover if to run Task with Domain Account it works too.
    Checked Run with highest privileges, changed "Configure for" field, tried different arguments (-noprofile, -noexit, -executionpolicy bypass, -command, -file,") - no luck.
    Didn't you try to make it work with SYSTEM account?
    Thanks.

    Hi fapq,
    Try this link task schedulers
    Note
    To identify tasks that run with system permissions, use a verbose query (/query/v). In a verbose query display of a system-run task, the Run As User field has a value of NT AUTHORITY\SYSTEM and
    the Logon Mode field has a value of Background only.
    Naveen Basati

  • How to run Powershell script (function) through Windows Task Schduler ??

    Hello All,
    i have Powershell script which is created as a function. I have to give parameters to run the script. And it is working fine. Now i want to run this script through windows task scheduler but it is not working. I dont know how to call powershell function
    through task scheduler.
    From command line i run it like this:
    . c:\script\Get-ServiceStatusReport.ps1
    dir function:get-service*
    Get-ServiceStatusReport -ComputerList C:\script\server.txt -includeService "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail mail01.xxx.gov.pk
    In windows Task scheduler I am giving this: it runs but i dont receive any output :
    Program/Script:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Parameter:
    -file ". 'Get-ServiceStatusReport.ps1 -ComputerList C:\script\server.txt -includeService  "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail  mail01.xxx.gov.pk'"
    Please HELP !!!

    Thanks for the reply:
    The script is already saved as Get-ServiceStatusReport.ps1 .
    On powershell it does not run like .\Get-ServiceStatusReport.ps1 (parameter).
    But i have to call it as function:
    Like this:
    Get-ServiceStatusReport -ComputerList C:\script\server.txt -includeService "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail mail01.xxx.gov.pk
    As you said:
    I tried to run it like this:
    Program/Script:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Parameter:
    -file "c:\script\Get-ServiceStatusReport.ps1 -ComputerList C:\script\server.txt -includeService  "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail  mail01.xxx.gov.pk'"
    But its not working , on scheduler its giving error: (0xFFFD0000)
    Please HELP !!!
    WHOLE SCRIPT:
    function Get-ServiceStatusReport
    param(
    [String]$ComputerList,[String[]]$includeService,[String]$To,[String]$From,[string]$SMTPMail
    $script:list = $ComputerList
    $ServiceFileName= "c:\ServiceFileName.htm"
    New-Item -ItemType file $ServiceFilename -Force
    # Function to write the HTML Header to the file
    Function writeHtmlHeader
    param($fileName)
    $date = ( get-date ).ToString('yyyy/MM/dd')
    Add-Content $fileName "<html>"
    Add-Content $fileName "<head>"
    Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
    Add-Content $fileName '<title>Service Status Report </title>'
    add-content $fileName '<STYLE TYPE="text/css">'
    add-content $fileName "<!--"
    add-content $fileName "td {"
    add-content $fileName "font-family: Tahoma;"
    add-content $fileName "font-size: 11px;"
    add-content $fileName "border-top: 1px solid #999999;"
    add-content $fileName "border-right: 1px solid #999999;"
    add-content $fileName "border-bottom: 1px solid #999999;"
    add-content $fileName "border-left: 1px solid #999999;"
    add-content $fileName "padding-top: 0px;"
    add-content $fileName "padding-right: 0px;"
    add-content $fileName "padding-bottom: 0px;"
    add-content $fileName "padding-left: 0px;"
    add-content $fileName "}"
    add-content $fileName "body {"
    add-content $fileName "margin-left: 5px;"
    add-content $fileName "margin-top: 5px;"
    add-content $fileName "margin-right: 0px;"
    add-content $fileName "margin-bottom: 10px;"
    add-content $fileName ""
    add-content $fileName "table {"
    add-content $fileName "border: thin solid #000000;"
    add-content $fileName "}"
    add-content $fileName "-->"
    add-content $fileName "</style>"
    Add-Content $fileName "</head>"
    Add-Content $fileName "<body>"
    add-content $fileName "<table width='100%'>"
    add-content $fileName "<tr bgcolor='#CCCCCC'>"
    add-content $fileName "<td colspan='4' height='25' align='center'>"
    add-content $fileName "<font face='tahoma' color='#003399' size='4'><strong>Service Stauts Report - $date</strong></font>"
    add-content $fileName "</td>"
    add-content $fileName "</tr>"
    add-content $fileName "</table>"
    # Function to write the HTML Header to the file
    Function writeTableHeader
    param($fileName)
    Add-Content $fileName "<tr bgcolor=#CCCCCC>"
    Add-Content $fileName "<td width='10%' align='center'>ServerName</td>"
    Add-Content $fileName "<td width='50%' align='center'>Service Name</td>"
    Add-Content $fileName "<td width='10%' align='center'>status</td>"
    Add-Content $fileName "</tr>"
    Function writeHtmlFooter
    param($fileName)
    Add-Content $fileName "</body>"
    Add-Content $fileName "</html>"
    Function writeDiskInfo
    param($filename,$Servername,$name,$Status)
    if( $status -eq "Stopped")
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=left ><b>$servername</td>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=left ><b>$name</td>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=left ><b>$Status</td>"
    Add-Content $fileName "</tr>"
    else
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td >$servername</td>"
    Add-Content $fileName "<td >$name</td>"
    Add-Content $fileName "<td >$Status</td>"
    Add-Content $fileName "</tr>"
    writeHtmlHeader $ServiceFileName
    Add-Content $ServiceFileName "<table width='100%'><tbody>"
    Add-Content $ServiceFileName "<tr bgcolor='#CCCCCC'>"
    Add-Content $ServiceFileName "<td width='100%' align='center' colSpan=3><font face='tahoma' color='#003399' size='2'><strong> Service Details</strong></font></td>"
    Add-Content $ServiceFileName "</tr>"
    writeTableHeader $ServiceFileName
    #Change value of the following parameter as needed
    $InlcudeArray=@()
    #List of programs to exclude
    #$InlcudeArray = $inlcudeService
    Foreach($ServerName in (Get-Content $script:list))
    $service = Get-Service -ComputerName $servername
    if ($Service -ne $NULL)
    foreach ($item in $service)
    #$item.DisplayName
    Foreach($include in $includeService)
    write-host $inlcude
    if(($item.serviceName).Contains($include) -eq $TRUE)
    Write-Host $item.MachineName $item.name $item.Status
    writeDiskInfo $ServiceFileName $item.MachineName $item.name $item.Status
    Add-Content $ServiceFileName "</table>"
    writeHtmlFooter $ServiceFileName
    function Validate-IsEmail ([string]$Email)
    return $Email -match "^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"
    Function sendEmail
    param($from,$to,$subject,$smtphost,$htmlFileName)
    [string]$receipients="$to"
    $body = Get-Content $htmlFileName
    $body = New-Object System.Net.Mail.MailMessage $from, $receipients, $subject, $body
    $body.isBodyhtml = $true
    $smtpServer = $MailServer
    $smtp = new-object Net.Mail.SmtpClient($smtphost)
    $validfrom= Validate-IsEmail $from
    if($validfrom -eq $TRUE)
    $validTo= Validate-IsEmail $to
    if($validTo -eq $TRUE)
    $smtp.UseDefaultCredentials = $true;
    $smtp.Send($body)
    write-output "Email Sent!!"
    else
    write-output "Invalid entries, Try again!!"
    $date = ( get-date ).ToString('yyyy/MM/dd')
    sendEmail -from $From -to $to -subject "Service Status - $Date" -smtphost $SMTPMail -htmlfilename $ServiceFilename

  • OSD - Task Sequence to run powershell script

    Hello,
    I'm building up an image with OSD and will be layering some components to meet our needs with some powershell scripts. At the moment we will not have this device add itself to the domain so it'll be in a workgroup. The scripts are on a share that everyone has
    read access to. Should I add a task sequence that will map a drive letter with domain credentials and have the task sequence call the script from that drive letter?

    That is possible to do, but why would you not create a package/application with the script and let it download and run locally? 
    Daniel Ratliff | http://www.PotentEngineer.com

  • Need to run powershell script in a bat file

    I have a ps1 file with the following:
    Get-ADUser -Filter * -SearchBase "ou=<HOSPOU>,ou=Domain Users and Groups,dc=<hospdomain>,dc=local" -Properties Description,EmailAddress| Select-Object -Property Name,SamAccountName,Description,EmailAddress|Export-Csv "\\<server>\home2$\information
    services\IS STAFF\Documentation\AD Info\smcusers.csv";
    I have a bat file:
    @ECHO OFF
    SET ThisScriptsDirectory=%~dp0
    SET PowerShellScriptPath=%ThisScriptsDirectory%smcusers.ps1
    %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command import-module ActiveDirectory "%PowerShellScriptPath%";
    But while it launches powershell with the AD module, It apparently cannot read the ps1 file.
    I get:
    H:\>C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command i
    mport-module ActiveDirectory "H:\smcusers.ps1";
    Import-Module : A positional parameter cannot be found that accepts argument 'H
    :\smcusers.ps1'.
    At line:1 char:14
    + import-module <<<<  ActiveDirectory H:\smcusers.ps1;
        + CategoryInfo          : InvalidArgument: (:) [Import-Module], ParameterB
       indingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
       .Commands.ImportModuleCommand
    I have tried to modify the parameters 
    %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command import-module ActiveDirectory -File "%PowerShellScriptPath%";
    Still no luck.
    I need to be able to run this as a scheduled task.
    Karon W

    Apparently I don't know where to put everything.
    I have a single line:
    %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit import-module ActiveDirectory; -Command {Get-ADUser -Filter * -SearchBase "ou=Shannon Memorial,ou=Domain Users and Groups,dc=shannonhealth,dc=local" -Properties Description,EmailAddress|Select-Object
    -Property Name,SamAccountName,Description,EmailAddress|Export-Csv "\\svr-resource2\home2$\information services\IS STAFF\Documentation\AD Info\smcusers.csv"}
    This is the response:
    H:\>C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit import-mod
    ule ActiveDirectory; -Command {Get-ADUser -Filter * -SearchBase "ou=Shannon Memo
    rial,ou=Domain Users and Groups,dc=shannonhealth,dc=local" -Properties Descripti
    on,EmailAddress  | Select-Object -Property Name,SamAccountName,Description,Email
    Address  | Export-Csv "\\svr-resource2\home2$\information services\IS STAFF\Docu
    mentation\AD Info\smcusers.csv"}
    'Select-Object' is not recognized as an internal or external command,
    operable program or batch file.
    I modified to 2 lines:
    %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit import-module ActiveDirectory;
    Get-ADUser -Filter * -SearchBase "ou=Shannon Memorial,ou=Domain Users and Groups,dc=shannonhealth,dc=local" -Properties Description,EmailAddress|Select-Object -Property Name,SamAccountName,Description,EmailAddress|Export-Csv "\\svr-resource2\home2$\information
    services\IS STAFF\Documentation\AD Info\smcusers.csv"
    This is the response:
    H:\>C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit import-mod
    ule ActiveDirectory;
    PS H:\> exit ************I had to type*****************
    H:\>Get-ADUser -Filter * -SearchBase "ou=Shannon Memorial,ou=Domain Users and Gr
    oups,dc=shannonhealth,dc=local" -Properties Description,EmailAddress  | Select-O
    bject -Property Name,SamAccountName,Description,EmailAddress  | Export-Csv "\\sv
    r-resource2\home2$\information services\IS STAFF\Documentation\AD Info\smcusers.
    csv"
    'Get-ADUser' is not recognized as an internal or external command,
    operable program or batch file.
    If I paste the command in before I type exit, it works. 
    If I paste:
    %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit import-module ActiveDirectory;
    I am put in the ad powereshell
    Then I paste:
    Get-ADUser -Filter * -SearchBase "ou=Shannon Memorial,ou=Domain Users and Groups,dc=shannonhealth,dc=local" -Properties Description,EmailAddress|Select-Object -Property Name,SamAccountName,Description,EmailAddress|Export-Csv "\\svr-resource2\home2$\information
    services\IS STAFF\Documentation\AD Info\smcusers.csv"
    and I get the expected output.
    What do I need to have in the bat file so the 2nd line of the script will run? and where does it go?
    Karon W

  • Scheduled Task to run as Local System cannot access the Netlogon Share in Windows 8.1

    I've created a Scheduled Task that is setup to run as the local System Account which uses cscript.exe to execute a VBScript residing on the Domain Netlogon Share. It works perfectly on Windows 7, but fails miserably on Windows 8.1. When I open a command
    prompt as the System account and try to run the script from the Netlogon share manually, I get the following error:
    CScript Error: Loading script \\<FullyQualifiedomainName>\Netlogon\xyz.vbs failed (The account used is a computer account. Use your global user account or local user account to access this server. ).
    Is there something different I need to set in Windows 8 to get this to run?
    Thank you!!
    Eric Myers

    Hi Eric,
    What's the result of Arnav's question?
    How did you set it? Please set it as the following steps:
    1.Go to Start > Administrative Tools > Task Scheduler
    2.In the Task Scheduler window double click your task, and on the "General" tab, under "Security options" section,  click the "Change User or Group" button.
    4.Make sure "From this location" is set to the local machine name (to change click "Locations" button and select the local computer name)
    5.Type "SYSTEM" in the text box and press ok . Under "When running the task, use the following user account:" you should see "NT AUTHORITY\SYSTEM".
    Karen Hu
    TechNet Community Support

  • KM Scheduler Task not running

    Hello All,
    I have created a scheduler task for the , for the same I have created a PAR file , have successfully Build the project and deployed , Have configured the time in the Global services . But for some reason I could not see the task being running in the "Component Monitor" (when I select the Services-->scheduler >select one of the CM systems (have two currently)>click on on the CM system ) I could not see my custom task .
    As well as When I go to "Service configuration" --> Portal Application , there also I could not see my custome application .
    Initially whenever there use to be any error (for example -- CM systems not assigned etc etc ).
    Is it something I am missing while deployement , Or has it being deployed properly?
    Regards,
    Ronniee

    Hello Detlev,
    Any Inputs on this please.
    I have opened a new thread but a different Query
    http://forums.sdn.sap.com/thread.jspa?threadID=2155357
    Regards,
    Ronniee.

Maybe you are looking for

  • Issue with SSRS Loading Report from Definition From Assembly

    I am using SharePoint 2010. I created web-part where there is report viewer control. On the page load of the control. I am writing below codes to load report from definition. Web part is not giving any error but also not lading report. I tried to mak

  • Mail.app no longer working (OS 10.6.8)

    Apple MacBook 2G Hz Intel Core Duo 2008 (black) OS 10.6.8 Mail.app not opening.....wrong version! There has been no advice on what to do/support or explanation. For a few months I have no longer been able to open Mail.app. I have tried a backup older

  • Can I migrate from an external hard drive to new Macbook Pro?

    Can I migrate my Macbook 13" Aluminum Late model 2008 data from it's external hard drive to my new Macbook Pro?  I have a complete back up of my old Macbook on that drive, but there is no way to connect that to the new Macbook Pro (no firewire etc on

  • Save as postscript problem

    the .ps file created is getting "no access" privileges on "group" and "others". his situation coses my backup to not backup thus files. any way i can do postscript file directly from the print button? like it was on classic.??

  • WDS PXE Uefi not working in AD integrated mode, TFTP to slow

    Dear all 1 Physical host: W2k12R2, 1 Hyper-V virtual switch. 1 Hyper-V VM with W2k12R2 DC with DNS, DHCP, WDS. 1 Empty Hyper-V VM Generation 2 UEFI booting from network. Problem: Error "PXE-E16: No offer received" on the empty Hyper-V VM when trying