Tidal vs Powershell

Hi,
Visited this one before with limited success but now its time to try again.
Platform is TES 6.1.0.212 running on Solaris x86, CM is on RH linux, agent on windows server 2003.
I'm attempting to automate some MS excel work via powershell. I have a script that works fine when called interactively or via a batch file. However, when calling either through TIDAL I run into issues. I'm sure most of these are going to be security settings in windows but working out what to fix is proving somewhat problematic.
For Powershell I have "set-ExecutionPolicy RemoteSigned" and the agent has the necessary rights as defined in the install guide eg "run as a batch job" etc.
For the particular script I'm running I believe its failing because the tidal runtime user needs to have web proxy credentials supplied.
Taking that as a starting point how might those details be defined?
The script is attached if anyone wants to play with it. It will need the extension changing to from ".txt" to ".ps1" The errors seen when  run via TIDAL are below.
Exception calling "Open" with "1" argument(s): "Microsoft Office Excel cannot a
ccess the file 'http://www.simple-talk.com/blogbits/philf/rainfall.html'. There
are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open wor
kbook."
At C:\temp\cambridge_rain.ps1:19 char:28
+ $wb = $Excel.Workbooks.Open <<<< ("http://www.simple-talk.com/blogbits/philf/
rainfall.html")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation
Exception getting "Range": "Exception calling "get_Range" with "2" argument(s):
"Exception from HRESULT: 0x800A03EC""
At C:\temp\cambridge_rain.ps1:56 char:13
+ $excel.Range <<<< ("H2").Select()
    + CategoryInfo          : NotSpecified: (:) [], GetValueInvocationExceptio
   n
    + FullyQualifiedErrorId : CatchFromBaseParameterizedPropertyAdapterGetValu
   e
Property 'FormulaR1C1' cannot be found on this object; make sure it exists and
is settable.

Success!
Most of the work is fighting through windows security but they key part is installing the TIDAL agent using the user account doing the work. It needs to be installed and run as that user instead of using the local system account or being installed by a local windows administrator.
I now have a working instance of excel running completely unattended under TIDAL control.

Similar Messages

  • Powershell, WMIC and remote execution in Tidal

    Anyone else leveraging these tools to remotely execute against application/database tiers? We are perfroming basic activities - stop/start service, remote batch file execution, file operational activities. We are trying to simplify our toolsets but in addtion make them more powerful and extend the usabiliuty of tidal in our enterprise. I am wondering what other creative things people have done?
    Marc

    Here's a little more advance technique we put together.. a little trick to do a dynamic varset with powershell w/ API
    we detect a file then count the file rows, we then do some math, round the result and set that integer into a number variable (global) this is then used as the seconds in a downstream "sleep" job to dynamically postpone retrieving a return file giving the vendor time to process it through their system and return a file to us.
    Job details
    CMD POWESHELL
    PARAMS
    $trans = Get-Content '\\gmo\dev\app\tidal\test\Confirmation.csv';
    $FTP_SleepTime =  [Math]::Round($trans.Count * .01  );
    Write-Host Sleep time should be a round number $FS_SleeptTime;
    invoke-command -scriptblock {d:\TIDAL\Scheduler\Client\sacmd.exe varset -n FLAG_FTPSleepTime -v $FTP_SleepTime}
    Environment
    POWERSHELL 2.0 on Windows Server 2008 O/S
    Tidal Client installed locally  on Agent D:\ drive with it's default alias pointing to it's opwn database environment
    Client ver 5.3.1.317
    Agent ver 3.0.1.14
    Master ver 5.3.1.318

  • PowerShell and Tidal

    I'm looking to get Multiple Windows server rebooted using PowerShell script in Tidal. Does anyone know how to use global variable using multiple servers. ?? Any Help would be appreciated.

    Sounds like you are looking to do some automation surrounding microsoft patching or something like that.
    I would not go about it with a global variable... I think there may be a character limitation on a var value.
    Powershell is pretty powerfull and can easily do the task, you can get as fancy as you want...  Tidal can take mulitple powershell
    statements. We often do this and leverage exit codes for different scenarios. using multiple ifs.
    if (condition met) {Do this}  else {Do Else} ; Exit(###);
    Then Tidal takes action based on exit code (alert, send email, etc)
    From a Tidal/Powershell perspective you need to consider a few things
    Security ... the runtime user needs access to all servers in the list in order to execute a shutdown or you pass it credentials. 
    Tidal Agent config
    Powershell commands can have issues with double quotes in params depending on how its used... so we avoid and each agent tagent.ini has this config switch
    [config]
    substticks=n
    Target Servers may need same version of powershell as agents and have their execution policys set properly (depending on technique used)
    Active Directory you may be organized to take advantage of server names
    Workflow/Design
    AD
    You could have Tidal Powershell get a list from AD, generate a list, then reboot for each object..
    List
    Another Simple way would be to use powershell to determine the list based on critera or supply it a list. The simple way is something like this
    restart-computer (get-content \\SomeNetworkShare\MS_PatchWeekend_ServerReboot_List.txt) ;
    Tidal Groups with Group variables
    Ad-Hoc
    Maybe you want to be able to reboot servers ad-hoc so you could create a template that takes a group variable and passes that server name to the powershell restart-computer cmdlet.
    Patch Weekend job group
    Depending on size of the environment you could have a job set that is "scheduled" on patch weekends that is made up of mulitple template groups that leverage job name to pass server name to the powershell restart-computer cmdlet (jobname=servername). You could also have some sort of secondary powershell statement or second job that lets you know when server is back up...
    Other
    Here's a case where it finds servers to reboot and there are many examples on the internet to borrow and learn from.
    http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/20/use-powershell-to-find-servers-that-need-a-reboot.aspx
    Hope this helps!
    Marc

  • 64 bit Powershell with 32 bit Tidal

    Hi All, I'm wondering if someone could assist me. Here is my scenario:
    I have a powershell script that is performing a P2Vof a server. It runs locally on the tidal server and connectes to the SCVMM server to perform the P2V.
    I have a batch script that calls this P2V script
    When I run the powershell script locally on the Tidal server it works fine and the P2V is created
    When I run the batch file that calls the powershell script it works fine and the P2V is created
    I created a Tidal job and pointed to the batch file. The job runs but the P2V isn't created
    I have added some debugging into the powershell script which is dumping stuff into a text file so I know the powershell script is running
    It seems like the script is functioning fine except when it comes to the P2V creation portion
    I have read other posts and it seems to me the issue may be in that my powershell script has to use a 64 bit SCVMM snapin which means I have to use the 64 bit version of powershell. Tidal is a 32 bit application so I think its having an issue using the SCVMM snapin even though its calling the 64 bit powershell version.
    Does anyone have any suggestions I can try to get around this?

    Is your server 64 bit?
    what are your tsagent.ini settings for on the server? this can have an impact on quotes and powershell in particular
    our is
    [config]
    substticks=n
    you could specify the 32bit version of Powershell if you needed to on the command line
    %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe
    %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

  • Privileges to Start / Stop / Pause Tidal Master

    Hi Team,
    Please your advise on what's the minimum level of privilege in a Windows environment that a user account needs to have to be able to Stop/Start/Pause the Tidal Master.
    We think we should belong to the Administrators group to be able to action the above.
    Our Security team has raised concerns on we getting to much access into that box if we get Admin rights.
    Thanks.

    You could work with the system administrators to grant all the appropriate privileges to stop/start services using an MMC snap-in  We do that with our operations team... they can stop/start tidal services (master/agent) but they can't logon to the servers themselves. System Admins have tools for setting this up. You could also add runtime users and possibly automate.
    however, if I am responsible for Tidal Administration and application, I would want to be able to logon to the infrastructure that runs the master (or agents) it just makes sense from a troubleshooting perspective to have local access.(App logs, System Log, Event logs, etc.). But responsibilities and roles vary from company to company.
    I wasn't sure if you meant manually (above) or automated but we do some autmation of shutdown for maintenance using Tidal jobs for maintenance weekends like MS patches (using a combination of powershell and api jobs)
    Marc

  • Powershell vs Tidal6

    Hi,
    I'm working on automating some excel work using powershell. Environment is TES 6.0.3 on solaris with the agent on a windows7 x64 system.
    The job calls a simple one-line bat script which is "powershell -command c:\tidal\autoexcel.ps1".
    The script works fine when called from a command window however when TES executes it I get a load of errors which I'm assuming are environment related. In essence it looks like excel can't find a load of embedded functions.
    The sample code can be found here. Its the charting of the weather data in Excel section.
    http://www.simple-talk.com/dotnet/.net-tools/com-automation-of-office-applications-via-powershell/
    I've tried creating an env.bat file to reproduce my command line working environment but it hasn't helped.
    Any ideas anyone?
    Cheers
    Joe

    We are running 5.31 but ipowershell should behave the same in 6x
    Powershell tips
    It can be tricky sometimes with powershell (especially gettign remote execution working) but if you are getting security issues you probably are restricted and need "signed" scripts.. Which depending on your policies may be required... but it wasn't worth the pain to our company.
    check it by running a powershell command: get-executionpolicy
    We set ours to unrestricted (use set-executionpolicy unrestricted)
    If you are running 64 Bit you need to do for both  32 bit and 64 bit versions
    if you intend to do remoting useEnable-PSRemoting and follow the prompts
    Here's an example where we reach out to an application server (FTP server) and trigger it to run an FTP task for us (send a file):
    Invoke-Command -computername -scriptblock {"" '-start:""' -p:SourceFileFromAPI: -waitsecs:60 -noxfers:1}
    Quotes can be a real pain with how Tidal Agents interprets the string so don't get frustrated if it works via powershell command line but won't work as a job. We discovered a defect in the way tidal handled quotes with powershell and worked with Cisco to put in a fix. we run agent 3.0.2.03 (If you read the readme files you'll find there's a switch:
    3.0.2.03
    HOT - CSCtv19905 - Fix to BUG00620 (substituting ticks with quotes, compat with old agent) caused
         problems for some customers.
    FIX - Added new tagent.ini parameter, substticks=y|n, to control.  Yes is default for compatibility
         with old agent.
    Path to Agent install \Agent\bin\tagent.ini
    [config]
    substticks=n
    [TIDAL_AGENT_1]
    Other tips
    We installed powershell 2.0 on source and target, you need to keep versions consistent
    You can run mutiple statements in a job... reducing the number of jobs with a semicolon ; Last statement does not have a semi-colon
    Use Write-Host like you would "echo" to insert comments (all are picked up in output)
    Exit Codes: you can force and standardize exit codes easily by using exit(###); as one of your statements, which is a cool way to trigger multiple actions like sending different "scenario" emails based on results with just one job, etc)
    You can run "agentless" with powershell. How about stopping or starting services remotely?
    set-service -computerName Targetserver -name TargetServices -status Running -passthru
    We also run all our file operations with powershell (it is much more flexible and reliable that other commands)
    We rarely use scipts, we mostly put basic commands or create functions directly in parameters
    Function copy-file-force              
    {  Bunch of Commands }
    copy-file-force  Param1, Param2, etc
    powershell in combination with powershell makes a poweful combination for rapid job development.
    We have about 4000 powershell jobs defined and active in our environment

  • Is it possible to catch a PowerShell script output when an exit code is setted?

    Hi,
    i'm using TEO 2.1.2 with the hotfixes from 1 to 12 already installed and i have a problem using the "Execute Windows PowerShell Script" in reading the output of a PowerShell script if an exit code is expressly setted . For example if i try to execute a script like:
    the output given by the activity is only 0 (like the exit code).
    This is a problem if i use a script with multiple exit codes corrisponding to different kind of situations and different outputs like the following:
    if($flag -eq "0")
       Write-output "Hello"
       exit 0
    elseif ($flag -eq "1")
       Write-output "Error 1"
       exit 1
    else
      Write-output "Error 2"
      exit 2
    or if i call an executable which exit codes i want to identify by a readable description.
    Anyone knows a way to solve this issue?
    Thanks a lot,
    bye.
    Giulio

    Thanks Shaun,
    i was already looking toward this kind of approch, but i was also curious if there was a different way of doing this.
    Anyway just a little annotation about your line of code, in Tidal 2.1.2 at least, Write-host doesn't work right, echo or Write-Output are fine but Write-host seems to be ignored. To the following script:
    the output is
    Maybe i'm missing something. Regarding an upgrade, as a devoloper i'd really like to try the improvement of the new version but this is not a decision I can make.
    Thank you,
    bye.
    Giulio

  • Running Exchange 2010 PowerShell Scripts

    Hello,
    I have a PowerShell Script which calls PSSnapins for Exchange tools.  The Exchange Management Tools are installed on the Tidal Server
    The Script works fine by itself, I have executed it as the tidal users on the Tidal Server. I have also created a batch file to execute the Powershell script, which also works on the tidal server.
    However when I run the job in Tidal it doesn't run correctly by that I mean it will run the none Exchange pieces.  In the Output tab it shows:
    Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.Exchange.Management.PowerShell.E2010' is not installed on this machine.
    At E:\PowerShell\DailyChecks\Dag_daily.ps1:7 char:13
    + Add-PSSnapin <<<<  Microsoft.Exchange.Management.PowerShell.E2010
        + CategoryInfo          : InvalidArgument: (Microsoft.Excha...owerShell.E2
       010:String) [Add-PSSnapin], PSArgumentException
        + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
       dPSSnapinCommand
    Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.Exchange.Management.Powershell.Support' is not installed on this machine
    These Scripts also work via Windows Task Scheduler as written  I would really like to get these to work in Tidal.  We are Tidal 5.3.1. 
    Any help would be greatly appreciated.
    Lee Merrill

    I have struggled with a similar issue with Sharepoint snapin with performing a backup
    I can give a couple of suggestions
    Add snapin to default profiles
    We also see a difference in 64 vs 32 bit oprerations
    we had to add to both versions using a local profile.ps1 and adding a line
    Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
    C:\Windows\System32\WindowsPowerShell\v1.0
    C:\Windows\SysWOW64\WindowsPowerShell\v1.0
    Execute remotely
    Slightly different setup on our side
    I am trying to invoke-command on the remote sharepoint server =
    ( you have to set up psremoting, etc)
    Invoke-Command -ComputerName -scriptblock { E:\Backup\BackupSite.ps1}
    Similarly I  can execute the backup.ps1 with no issue on the server but can't from the tidal job.
    I'll let you know if we find a fix
    I am thinking double hop at this point and need to trust for delegation, etc
    Marc

  • Cannot send email from Powershell on Mailbox Role

    Hi,
    I am trying to send an email from Powershell on Mailbox role of Exchange server. I have installed Symantec Mail Security on Mailbox Role.
    When I try to send email using Powershell, I got the following error.
    PS C:\a> Send-MailMessage -to [email protected] -Subject "Alert Closed.. Service is restarted on Computer" -from
    [email protected] -Body "The service was found stopped on Computer it was started automatically and it is now running normally." -bodyasHTML -priority High -SmtpServer smtp.domain.com
    Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.3.2 Service not active
    At line:1 char:1
    + Send-MailMessage -to [email protected] -Subject "Alert Closed.. Service is ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
        + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
    This command is working fine on every server except exchange server (CAS, Mailbox). Firewall is off on the servers.
    Any help will be highly appreciated.
    Regards,
    Anees

    Hi,
    Please check the similar thread .
    http://social.technet.microsoft.com/Forums/exchange/en-US/ef699832-8da9-4709-9a50-c6223b13bd95/sendmailmessage-returns-the-server-response-was-432-service-not-available?forum=exchangesvrsecuremessaginglegacy
    smtp server (smtp.domain.com) is rejecting the connection from the
     Mailbox role of Exchange server.
    So please allow the mailbox server ip address on the smtp server's (i.e. smtp.domain.com)
    receive connector to get it done 
    Regards
    S.Nithyanandham
    Thanks S.Nithyanandham

  • How can I display a SP 2010 out of the box workflow's task assignees via powershell?

    There are days where one of the 250+ workflows at the site has attempted to send email to someone no longer at the company.
    I would like to find a way to go through the farm and display all the list URLs that have workflows, and the mail addresses associated to the workflows.
    This way I can track down the workflows that need to be updated to remove the missing users.
    I have started a bit of script to do this. In my script, I just had a site collection - I figured that if I can get that to work, then surely wrapping another loop for the rest of the farm won't be bad. 
    However, for some reason, I am not seeing the output that I expected to show the mail addresses.
    I am hoping a different set of eyes might see what I am missing. It was my understanding that the AssociationData property was XML that contained information about the assignees for tasks, the carbon copy list, etc.
    Maybe I misunderstood something that I read?
    $outLoc = "d:\temp\wfdata.txt"
    $web = Get-SPWeb -Identity "http://myfarm/sites/it/"
    foreach ($list in $web.Lists)
     $associationColl=$list.WorkflowAssociations
     foreach ($association in $associationColl)
           $association.AssociationData | Out-File $outLoc
    $web.Dispose()
    I want to thank you for the helpful tips that so often appear on this list. They help me when I am reading over old threads to figure out what to do. I am hoping that tips on this thread will likewise be helpful.

    Hi,
    With
    SPWorkflowAssociation.AssociationData property, we can get the assignees’ information. Your script can
    be able to retrieve a XML format data which contains the user name we need:
    So the next step would be getting the user name by parsing the XML data we got.
    The two links below will show how to parse XML with PowerShell:
    http://stackoverflow.com/questions/18032147/parsing-xml-using-powershell
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/26/use-powershell-to-parse-an-xml-file-and-sort-the-data.aspx
    With the user name, we can get the
    Email property of an user with the scripts as the link below provided:
    http://davidlozzi.com/2012/03/07/using-powershell-to-access-sharepoint-sites/  
    Best regards
    Patrick Liang
    TechNet Community Support

  • Error while updating a custom Windows Azure Diagnostics configuration xml from powershell. "Invalid update to extension reference for role"

    I am attempting to upload a manually edited WADConfig xml to my VM. The WAD service is functioning correctly, I needed to add some custom WinEventLogs. The prescribed steps result in an error.
    What am I overlooking?
    I am following these instructions:
    Step 5: Remotely install Diagnostics on your Azure Virtual Machine
    azure.microsoft.com/en-in/documentation/articles/cloud-services-dotnet-diagnostics/#virtual-machine
    $storage_name = "wadexamplevm"
    $key = "<StorageAccountKey>"
    $config_path="c:\users\<user>\documents\visual studio 2013\Projects\WadExampleVM\WadExampleVM\WadExample.xml"
    $service_name="wadexamplevm"
    $vm_name="WadExample"
    $storageContext = New-AzureStorageContext
    -StorageAccountName $storage_name -StorageAccountKey $key
    $VM1 = Get-AzureVM
    -ServiceName $service_name -Name $vm_name
    $VM2 = Set-AzureVMDiagnosticsExtension
    -DiagnosticsConfigurationPath $config_path
    -Version "1.*"
    -VM $VM1 -StorageContext $storageContext
    $VM3 = Update-AzureVM
    -ServiceName $service_name -Name $vm_name
    -VM $VM2.VM
    Unfortunately, I am receiving this error:
    Update-AzureVM : BadRequest: Invalid update to extension reference for role: XXXXXX and reference: IaaSDiagnostics.
    What's missing from the above script?

    Hi,
    Since Azure SDK 2.5 uses the extension model the diagnostics extension, the configuration and the connection string to the diagnostic storage are no longer part of the deployment package and cscfg. All the diagnostics configuration is contained within the
    wadcfgx. The advantage with this approach is that diagnostics agent and settings are decoupled from the project and can be dynamically enabled and updated even after your application is deployed. 
    Due to this change some existing workflows need to be rethought – instead of configuring the diagnostics as part of the application that gets deployed to each environment you can first deploy the application to the environment and then apply the diagnostics
    configuration for it.  When you publish the application from Visual Studio this process is done automatically for you. However if you were deploying your application outside of VS using PowerShell then you have to install the extension separately through
    PowerShell.
    There PowerShell cmdlets for managing the diagnostics extensions on a Cloud Service are -
    Set-AzureServiceDiagnosticsExtension
    Get-AzureServiceDiagnosticsExtension
    Remove-AzureServiceDiagnosticsExtension
    You can use the Set-AzureServiceDiagnosticsExtension method to enable diagnostics extension on a cloud service. One of the parameters on this cmdlet is the XML configuration file. This file is slightly different from the diagnostics.wadcfgx file. You can
    create this file from scratch by either following the article that you are referring to or  you can modify the wadcfgx file and pass in the modified file as a parameter to the powershell cmdlet.
    To modify the wadcfgx file –
    Make a copy the .wadcfgx.
    Remove the following elements from the Copy:
    <DiagnosticsConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
       <PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
         <StorageAccount name=" " endpoint="https://core.windows.net/" />
       </PrivateConfig>
       <IsEnabled>false</IsEnabled>
    </DiagnosticsConfiguration>
    Make sure the top of the file still has xml version and encoding –
       <?xml version="1.0" encoding="utf-8"?>
    Effectively you are stripping down the Wadcfgx to only contain the <PublicConfig> section and the <?xml> header. You can then call the PowerShell cmdlet along with the appropriate parameters for the staging slots and roles:
    $storage_name = ‘
    <storagename>’
    $key= ‘<key>’
    $service_name = '<servicename>'
    $public_config = '<thepublicconfigfrom_diagnostics.wadcfgx>'
    $storageContext = New-AzureStorageContext –StorageAccountName $storage_name –StorageAccountKey $key
    Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $public_config –ServiceName $service_name -Slot ‘Staging’ -Role ‘WebRole1’
    Hope this helps !
    Regards,
    Sowmya

  • Looking for help with PowerShell script to delete folders in a Document Library

    I'd like to create a PowerShell script to delete old folders in a Document library that are over 30 days old. Has anyone created something like this?
    Orange County District Attorney

    Hello Sid:
    I am trying to do the same and Iam running the script to delete the subfolders inside a folder  but I have some errors. 
    Could you please take a look?
    _______Script________
    $web = Get-SPWeb -Identity https://myportal.mydomain.com
    $list = $web.GetList("ar_mailingactivity")
    $query =  New-Object Microsoft.SharePoint.SPQuery 
    $camlQuery = '<Where><And><Eq><FieldRef Name="ContentType" /><Value Type="Computed">Folder</Value></Eq><Leq><FieldRef Name="Created" /><Value Type="DateTime"><Today OffsetDays="-30" /></Value></Leq></And></Where>'
    $query.Query = $camlQuery
    $items = $list.GetItems($query)
    for ($intIndex = $items.Count - 1; $intIndex -gt -1; $intIndex--)
       $items.Delete($intIndex);
    ________Errors_______
    Unable to index into an object of type System.Management.Automation.PSMethod.
    At C:\Script.ps1:2 char:22
    + $list =$webGetList <<<< "ar_mailingactivity"]
    + CategoryInfo
    :InvalidOperation: (ar_mailingactivity:String) [], RuntimeException
    + FullyQualifiedErrorID
    :CannotIndex
    You cannot call a method on  a null-valued expression.
    At c:\Script.ps1:6 char:24
    + $items = $list.GetItems <<<< ($query)
    + CategoryInfo
    :InvalidOperation: (GetItems:String) [], RuntimeException
    + FullyQualifiedErrorID
    :InvokeMethodOnNull

  • Powershell Script Send-zip not working when running in cmd

    I found there is powershell send-zip script available in technet.  I tested it and found that it works when the script is running under powershell env, but when it is calling in cmd env, I can see the zip file, but there is nothing in it.  If
    I add the "-noexit" switch it runs normally.  Anyone have ideas what might be happening?
    The orig codes is as following:
    function global:SEND-ZIP ($zipfilename, $filename) { 
    # The $zipHeader variable contains all the data that needs to sit on the top of the 
    # Binary file for a standard .ZIP file
    $zipHeader=[char]80 + [char]75 + [char]5 + [char]6 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0 + [char]0
    # Check to see if the Zip file exists, if not create a blank one
    If ( (TEST-PATH $zipfilename) -eq $FALSE ) { Add-Content $zipfilename -value $zipHeader }
    # Create an instance to Windows Explorer's Shell comObject
    $ExplorerShell=NEW-OBJECT -comobject 'Shell.Application'
    # Send whatever file / Folder is specified in $filename to the Zipped folder $zipfilename
    $SendToZip=$ExplorerShell.Namespace($zipfilename.tostring()).CopyHere($filename.ToString())
    SEND-ZIP C:\abc\a.ZIP C:\a\a.bak

    I've had the same problem with similar code found on another web site.
    The reason the zip file ends up being empty is that the temporary $ExplorerShell object you created is deleted when the send-zip function returns,
    and any incomplete copy operation that may still be ongoing at that time is aborted. (The copy operation is asynchronous, and continues after the CopyHere() function returns.)
    To work around this, you need to add a delay loop before you return, waiting for the copied object to appear in the zip.
    (Note that adding a fixed delay, like I've seen on other web sites, does not work: Small files appear almost immediately, whereas large file or worse still large subdirectory trees can take a long time to appear.)
    Try changing the end of your routine to something like...
    # Create an instance to Windows Explorer's Shell comObject 
    $ExplorerShell=NEW-OBJECT -comobject 'Shell.Application' 
    # Open the zip file object
    $zipFile = $ExplorerShell.Namespace($zipfilename.tostring())
    # Count how many objects were in the zip file initially
    $count = $zipFile.Items().Count
    # Send whatever file / Folder is specified in $filename to the Zipped folder $zipfilename 
    $SendToZip=$zipFile.CopyHere($filename.ToString())
    # Wait until the file / folder appears in the zip file
    $count += 1 # We expect one more object to be there eventually
    while ($zipFile.Items().Count -lt $count) {
        Write-Debug "$filename not in the zip file yet. Sleeping 100ms"
        Start-Sleep -milliseconds 100
    # Return deletes the $zipFile object, and aborts incomplete copy operations.

  • Unable to create web app with PowerShell - An update conflict has occurred

    I am trying to create a new Web Application using PowerShell. I need to use PowerShell because I need to create the Web App using classic authentication and not Claims authentication. the first time I created the Web App, everything went great. Ever since
    the first time, I get an error and the web app creation does not complete. Just as an FYI, I can create a new Web App using Central Admin, but that creates it with Claims authentication which I cannot use.
    Here is my PowerShell script
    New-SPWebApplication -Name "SharePoint2013 (82)" -ApplicationPool "SharePoint2013-82" -AuthenticationMethod "NTLM" -ApplicationPoolAccount (Get-SPManagedAccount "GLOBAL\SP_AppPool") -Port 82 -URL "http://sharepoint2013"
    Here is the error I get in PowerShell
    New-SPWebApplication : An update conflict has occurred, and you must re-try this action. The object SPWebApplication
    Name=SharePoint2013 (82) was updated by DOMAIN\SP_Administrator, in the powershell (13020) process, on machine SPWEB01.
     View the tracing log for more information about the conflict.
    At line:1 char:1
    + New-SPWebApplication -Name "SharePoint2013 (82)" -ApplicationPool "SharePoint201 ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (Microsoft.Share...PWebApplication:SPCmdletNewSPWebApplication) [New-SPWebA
       pplication], SPUpdatedConcurrencyException
        + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSPWebApplicationUnknown SQL Exception 547 occurred. Additional error information from SQL Server is included below.
    The DELETE statement conflicted with the REFERENCE constraint "FK_Dependencies1_Objects". The conflict occurred in database "SP_Config", table "dbo.Dependencies", column 'ObjectId'.
    The statement has been terminated.
    I also get  this error from the trace
    Unknown SQL Exception 547 occurred. Additional error information from SQL Server is included below.
    The DELETE statement conflicted with the REFERENCE constraint "FK_Dependencies1_Objects". The conflict occurred in database "SP_Config", table "dbo.Dependencies", column 'ObjectId'.
    The statement has been terminated.
    I have tried to resolve the issue by performing the following:
    Delete the partially created web app using Central Admin or PowerShell
    Clear the file system cache on all servers in the farm (Stopping wss timer job, Saving Copy of the
    cache.ini file from C:\Documents and Settings\All Users\application data\Microsoft\SharePoint\Config folder. Clearing all the .xml files from the location except cache.ini but Edit the cache.ini to have value 1. Starting the timer job)
    Use Products Configuration Wizard (no detach, just 'upgrade') - People have said to select the option to disconnect the server from server farm and revert back again at next step (so you actually do not disconnect), but there is no next step that I have
    encountered. You select 'disconnect', hit next, and the server disconnects.
    Restart all the servers in the farm
    Run the PowerShell script again...still get the same error
    I have tried it on multiple servers in the farm too.

    Hi Michael,
    I found a similar thread for you reference:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9ccef7bf-87a9-4849-b086-4db2d898f1d7/cannot-create-new-web-application-wss-30?forum=sharepointadminlegacy 
    If it doesn’t work, sometimes the issue might be caused by long time keep powershell opening and generating some cache files. So please try re-opening the powershell and test the issue again.
    http://blogs.msdn.com/b/ronalg/archive/2011/06/24/mount-spcontentdatabase-errors-on-2nd-and-subsequent-attempts-of-same-database.aspx?Redirected=true 
    http://www.oakwoodinsights.com/sharepoint-powershell-surprise/
    In addition, here is an article which explains the possible reason of the SQL error:
    http://technet.microsoft.com/en-us/library/ee513056(v=office.14).aspx
    Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected] .
    Rebecca Tu
    TechNet Community Support

  • Exchange Powershell return value from Get-command to variable.

    Hi
    I am trying to create a powershell-script for our monitoring-software.
    The script is supposed to establish a connection to our exchange-server mgmt-shell and execute this command:
    "Get-MailboxDatabaseCopyStatus"
    I have the connection in place, but am missing the knowledge of how to return the result of the command to my script, which I can then pass to our monitoring-software.
    (The script take 2 parameters - host and command eg. exch01.domain and Get-MailboxDatabaseCopyStatus).
    Current code:
    $statusAlive = "ScriptRes:Host is alive:"
    $statusDead = "ScriptRes:No answer:"
    $statusUnknown = "ScriptRes:Unknown:"
    $statusNotResolved = "ScriptRes:Unknown host:"
    $statusOk = "ScriptRes:Ok:"
    $statusBad = "ScriptRes:Bad:"
    $statusBadContents = "ScriptRes:Bad contents:"
    $pass = cat C:\securestring.txt | convertto-securestring
    $Cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "domain\administrator",$pass
    $host = $args[0]
    $command = $args[1]
    <#
    if (!$args[0]) {
    echo $statusUnknown"Host parameter is empty"
    exit
    if (!$args[1]) {
    echo $statusUnknown"Command parameter is empty"
    exit
    #>
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$host/powershell -Credential $cred
    Import-PSSession $session
    $command
    Remove-PSSession $session
    Now, how do I "catch" the value of the executed command and return it to a variable in the script?
    Best Regards,
    Soren

    Hmm.. doesnt seem to work quite right.
    I added "Echo $result" after "Remove-PSSession $session", but then I just get a bunch of information..
    Script tmp_c3a1c132-f4d9-4d61... {Get-IRMConfiguration, New-MailUser, Get-PublicFolderMigrationRequestSta...
    RunspaceId : 2d179364-2df3-483d-a192-f5f4ca9453bb
    Identity : DB02 - Specielle\EXCHANGE01
    Id : DB02 - Specielle\EXCHANGE01
    Name : DB02 - Specielle\EXCHANGE01
    DatabaseName : DB02 - Specielle
    Status : Mounted
    InstanceStartTime : 01-03-2014 03:35:07
    LastStatusTransitionTime :
    MailboxServer : EXCHANGE01
    ActiveDatabaseCopy : EXCHANGE01
    ActiveCopy : True
    ActivationPreference : 1
    StatusRetrievedTime : 11-03-2014 08:30:15
    WorkerProcessId : 8124
    ActivationSuspended : False
    ActionInitiator : Unknown
    ErrorMessage :
    ErrorEventId :
    ExtendedErrorInfo :
    SuspendComment :
    RequiredLogsPresent :
    SinglePageRestore : 0
    ContentIndexState : Healthy
    ContentIndexErrorMessage :
    ContentIndexVersion : 1
    ContentIndexBacklog : 0
    ContentIndexRetryQueueSize : 0
    ContentIndexMailboxesToCrawl :
    ContentIndexSeedingPercent :
    ContentIndexSeedingSource :
    CopyQueueLength : 0
    ReplayQueueLength : 0
    ReplaySuspended : False
    ResumeBlocked : False
    ReseedBlocked : False
    MinimumSupportedDatabaseSchemaVersion : 0.121
    MaximumSupportedDatabaseSchemaVersion : 0.125
    RequestedDatabaseSchemaVersion : 0.125
    LatestAvailableLogTime :
    LastCopyNotificationedLogTime :
    LastCopiedLogTime :
    LastInspectedLogTime :
    LastReplayedLogTime :
    LastLogGenerated : 0
    LastLogCopyNotified : 0
    LastLogCopied : 0
    LastLogInspected : 0
    LastLogReplayed : 0
    LowestLogPresent : 0
    LastLogInfoIsStale : False
    LastLogInfoFromCopierTime :
    LastLogInfoFromClusterTime :
    LastLogInfoFromClusterGen : 0
    LogsReplayedSinceInstanceStart : 0
    LogsCopiedSinceInstanceStart : 0
    LatestFullBackupTime :
    LatestIncrementalBackupTime :
    LatestDifferentialBackupTime :
    LatestCopyBackupTime :
    SnapshotBackup :
    SnapshotLatestFullBackup :
    SnapshotLatestIncrementalBackup :
    SnapshotLatestDifferentialBackup :
    SnapshotLatestCopyBackup :
    LogReplayQueueIncreasing : False
    LogCopyQueueIncreasing : False
    ReplayLagStatus :
    DatabaseSeedStatus :
    OutstandingDumpsterRequests : {}
    OutgoingConnections :
    IncomingLogCopyingNetwork :
    SeedingNetwork :
    DiskFreeSpacePercent : 50
    DiskFreeSpace : 20.02 GB (21,498,761,216 bytes)
    DiskTotalSpace : 40 GB (42,946,523,136 bytes)
    ExchangeVolumeMountPoint :
    DatabaseVolumeMountPoint : E:\
    DatabaseVolumeName : \\?\Volume{e6cb407f-e4f2-11e2-93eb-005056ae239d}\
    DatabasePathIsOnMountedFolder : False
    LogVolumeMountPoint : F:\
    LogVolumeName : \\?\Volume{e6cb4087-e4f2-11e2-93eb-005056ae239d}\
    LogPathIsOnMountedFolder : False
    LastDatabaseVolumeName :
    LastDatabaseVolumeNameTransitionTime :
    VolumeInfoError :
    IsValid : True
    ObjectState : Unchanged
    RunspaceId : 2d179364-2df3-483d-a192-f5f4ca9453bb
    Identity : DB01 - Standard\EXCHANGE01
    Id : DB01 - Standard\EXCHANGE01
    Name : DB01 - Standard\EXCHANGE01
    DatabaseName : DB01 - Standard
    Status : Mounted
    InstanceStartTime : 01-03-2014 03:35:07
    LastStatusTransitionTime :
    MailboxServer : EXCHANGE01
    ActiveDatabaseCopy : EXCHANGE01
    ActiveCopy : True
    ActivationPreference : 1
    StatusRetrievedTime : 11-03-2014 08:30:15
    WorkerProcessId : 8140
    ActivationSuspended : False
    ActionInitiator : Unknown
    ErrorMessage :
    ErrorEventId :
    ExtendedErrorInfo :
    SuspendComment :
    RequiredLogsPresent :
    SinglePageRestore : 0
    ContentIndexState : Healthy
    ContentIndexErrorMessage :
    ContentIndexVersion : 1
    ContentIndexBacklog : 3
    ContentIndexRetryQueueSize : 0
    ContentIndexMailboxesToCrawl :
    ContentIndexSeedingPercent :
    ContentIndexSeedingSource :
    CopyQueueLength : 0
    ReplayQueueLength : 0
    ReplaySuspended : False
    ResumeBlocked : False
    ReseedBlocked : False
    MinimumSupportedDatabaseSchemaVersion : 0.121
    MaximumSupportedDatabaseSchemaVersion : 0.125
    RequestedDatabaseSchemaVersion : 0.125
    LatestAvailableLogTime :
    LastCopyNotificationedLogTime :
    LastCopiedLogTime :
    LastInspectedLogTime :
    LastReplayedLogTime :
    LastLogGenerated : 0
    LastLogCopyNotified : 0
    LastLogCopied : 0
    LastLogInspected : 0
    LastLogReplayed : 0
    LowestLogPresent : 0
    LastLogInfoIsStale : False
    LastLogInfoFromCopierTime :
    LastLogInfoFromClusterTime :
    LastLogInfoFromClusterGen : 0
    LogsReplayedSinceInstanceStart : 0
    LogsCopiedSinceInstanceStart : 0
    LatestFullBackupTime :
    LatestIncrementalBackupTime :
    LatestDifferentialBackupTime :
    LatestCopyBackupTime :
    SnapshotBackup :
    SnapshotLatestFullBackup :
    SnapshotLatestIncrementalBackup :
    SnapshotLatestDifferentialBackup :
    SnapshotLatestCopyBackup :
    LogReplayQueueIncreasing : False
    LogCopyQueueIncreasing : False
    ReplayLagStatus :
    DatabaseSeedStatus :
    OutstandingDumpsterRequests : {}
    OutgoingConnections :
    IncomingLogCopyingNetwork :
    SeedingNetwork :
    DiskFreeSpacePercent : 50
    DiskFreeSpace : 20.02 GB (21,498,761,216 bytes)
    DiskTotalSpace : 40 GB (42,946,523,136 bytes)
    ExchangeVolumeMountPoint :
    DatabaseVolumeMountPoint : E:\
    DatabaseVolumeName : \\?\Volume{e6cb407f-e4f2-11e2-93eb-005056ae239d}\
    DatabasePathIsOnMountedFolder : False
    LogVolumeMountPoint : F:\
    LogVolumeName : \\?\Volume{e6cb4087-e4f2-11e2-93eb-005056ae239d}\
    LogPathIsOnMountedFolder : False
    LastDatabaseVolumeName :
    LastDatabaseVolumeNameTransitionTime :
    VolumeInfoError :
    IsValid : True
    ObjectState : Unchanged
    I am only interested in the 2 "ContentIndexState" - how can I pick these 2 out and put them into a variable?
    I though the command "Get-MailboxDatabaseCopyStatus" would only display these two, since it is what happens if I run the command inside PowerShell on the server itself.

Maybe you are looking for

  • Using a Mac Mini Server quad Core i7 for FCPX ?

    I am a student trying to configure a final cut pro X edit system with a budget of around $4K. I have over 400 hours of video (some Hi-8 but mostly mini-DV tapes). For the Mini-DV tapes I plan on ingesting video into FCPX directly from the camera via

  • Oracle 8.1.7 Server Installation on a P4 Windows 2000 Server

    I am trying to Install Enterprise Oracle 8.1.7 on a P4 Windows 2000 Server Machine. I had a solution regarding the P4 bug, which asked the latest Service Pack for Win 2000 to be installed, the Oracle CD dump copied to hard disk and symcjit.dll to be

  • CMYK settings in Photoshop cc (2014) for Print in South Africa

    I am new to photoshop and print and need to know what CMYK settings are best for printing purposes in south Africa. I am using Photoshop cc (2014) Latest update. On Mac.  Project is aimed at a poster (420mm x 594mm) - roughly street pole size.  Thank

  • Pages as Movies

    How do websites like the below link have their different pages be movies? i.e. the transitions are great as one page fades out and the new one fades in? How do they do this? Is it layers of movies? Do they place movies in different keyframes and go t

  • Anonymous ftp configuration

    Hi, I'm trying to set up an anonymous ftp server on an Ultra 10 running solaris 8 and am having massive amounts of problems. I did download wu-ftp found on http://www.sunfreeware.com and I installed it but now cannot find the binary executables. I fo