Powershell and Taskscheduler

Hello
We are using Sharepoint 2013 and Windows 2008R2. When running a powershell script from a batch direct from the command line the output is redirected to a file.
If this is done through the task scheduler the output is not redirected to the file.
The logfile is programmed within the powershell script as function
Function LogWrite
  Param ([string]$logstring) 
  Add-content $Logfile -value $logstring -Verbose -
Do you have any idea
Cheers
Nickxx

Can you compare value of $Logfile by running it from batch direct and when running with Task scheduler. Also, is there any parameter passed from batch script into the powershell script, that maybe missed when creating the Task.

Similar Messages

  • Powershell and Sharepoint workflow

    Oke I got this a really strange problem.
    I got a ps1 file with powershell code in it. The code create a list item in sharepoint with all information and on the information I want to trigger a workflow.
    But now if I activated the ps1 file powershell as administrator(automatic) and then run the code thats in the file. But no Workflow tiggered in sharepoint the workflow is automatic activated when a new item is created.
    And the strange thing is if I open my script with notepad copy the text insert it into powershell and press enter my workflow runs...
    So any1 have an idea to fix this?

    Below is code snippet in c#.net for fetching all the attachements for a specific list item.
    try
                    // Set the Site Url
                    SPSite objSite = new SPSite("http://Testsite/");
                    using (SPWeb objWeb = objSite.OpenWeb())
                        objWeb.AllowUnsafeUpdates = true;
                        // Get the List
                        SPList objList = objWeb.Lists["MyList"];
                        // Get the item by ID
                        SPListItem objItem = objList.GetItemById(1);
                        // Get the attachments of the item
                        SPAttachmentCollection objAttchments = objItem.Attachments;
                        // Iterate the attachments
                        foreach (string fileName in objItem.Attachments)
                            // Perform action on
    the extracted attachment
     Hope it
    answer the questions.Any suggestions are appreciated.
    Cheers, Eliza

  • Powershell and -contains

    Hi, 
    I have a little problem with powershell and "contains"
    In this situation works well and return "true"
    $test = "where is the word"
    ($test).Contains("word")
    but in this other return always "false" 
    $test = Get-Process
    ($test).Contains("winlogon")
    Why? 
    Thanks
    Andrea Gallazzi
    windowserver.it - blog:
    andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights.

    Hi,
    Try looking at the ProcessName property:
    PS C:\Scripts\PowerShell Scripts\Misc Testing\1-10-2014> $test = Get-Process
    PS C:\Scripts\PowerShell Scripts\Misc Testing\1-10-2014> $test.ProcessName.Contains('winlogon')
    True
    EDIT: If I remember correctly, I believe this requires PS3+ though.
    EDIT2: This will work if you only have v2 (I'm sure there's a better way to do this, but this'll work in a pinch):
    PS C:\> $found = $false
    PS C:\> $test = Get-Process
    PS C:\> $test | ForEach { If ($_.ProcessName.Contains('winlogon')) { $found = $true } }
    PS C:\> $found
    True
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Powershell and robocopy pausing

    I am using powershell and Robycopy to move files from volume to another.  Server 2008R2 iSCSI volumes on
    It seems that powershell window occasionally pauses.  When I hit enter the process just starts up again.  It is taking more that a day to move 2TB of data.  Command is: robocopy h:\ j:\ /e /mov /R:5 /W:10 /log:c:\movedidson.log /TEE /NP /ETA
    Also an empty folder remains on the first drive.  Why is it not deleting the folders after it copies.
    Thanks,
    Mark

    Hi Mark,
    Total shot in the dark, perhaps this will help:
    http://social.technet.microsoft.com/Forums/en-US/ab36656d-bfbd-4ff1-ac7a-84e2ac975c1d/powershell-hangs?forum=winserverpowershell
    EDIT: Also, this isn't exactly a PowerShell question. You may be using PowerShell to launch robocopy, but that's pretty much the end of anything PowerShell related.
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Asking Again: Group Description Updated in Admin UI is not reflected in PowerShell and vice versa

    I've updated the Groups Description (About Me) using the GUI / Website.  Then running a script to output the Group's Description like:
    $siteUrl = "site url"
    $web = Get-SPWeb $siteUrl
    $web.SiteGroups
    $web.Dispose()
    The description doesn't change.  I can then update the Description of the group using PowerShell and close the window then and run the above code the changes are reflected.  However, the GUI / Website doesn't have the changes.  Very odd!
    raym

    Hi raym,
    Does this still work for you?
    I am rapidly losing my mind over this...
    Is there anything that you left out or perhaps assumed that Noobs (like myself) would already know or have considered? ;)
    I have tried about ten different solutions and Nothing works.
    All I get is plain text.
    Set
    Group Description to HTML via PS Script (This will explain what I have - from my original request of the same)
    Please!! If anyone can shed some light on this before I scrap SP altogether and revert back to DOS. It is the Only thing of Microsoft that actually worked. Oh! and AOE2!! ;)
    TIA,
    Neil

  • Windows Powershell and HP Open Test Architect (TDApiOle80)

    I'm not sure that this is the correct forum to place this in. Please feel free to move it if needed...
    I have a task to create a new script using powershell and the OTA. When trying to log into quality center via the open test architecture in powershell I get this error. 
    At my computer char:22+ $td.InitConnectionEx $qualityCenterLink+ ~~~~~~~~~~~~~~~~Unexpected token '$qualityCenterLink' in expression or statement.
    At my computer char:11+ $td.Login $qualityCenterUsername, $qualityCenterPassword+
          ~~~~~~~~~~~~~~~~~~~~~~
    This is the code that I am using.
    $td = New-Object -ComObject "TDApiOle80.TDConnection"
    $td.InitConnectionEx $qualityCenterLink
    $td.Login $qualityCenterUsername, $qualityCenterPassword
    This code currently works in a script written with VBscript. I am just modifying the td variable to use powershell instead of vbscript. Do you all have any idea what it is that is causing this not to run? Also, Is powershell compatible with the OTA? I am assuming
    so only because the OTA is a COM package.

    it appears it doesn't like the formatting. It doesn't know how to handle the varibles
    Powershell thinks thinks these are 2 variable next to each other
    $td.InitConnectionEx $qualityCenterLinkmaybe put $td.InitConnectionEx($qualityCenterLink)$td.Login $qualityCenterUsername, $qualityCenterPasswordPowershell thinks thinks these are variable next to each other, with a comma separating two of themmaybe put $td.Login ($qualityCenterUsername, $qualityPasswrod)Maybe you can do $td | get-member, may that will show you how the arguments should look. I have neverused the OTA, just guessing here.

  • Learning about Powershell and IPV6 for 70-410

    I was reading up on the 70-410 exam as I am trying to study up before I take it at the end of the month and it appears knowing Powershell and IPv6 is necessary. Alot of the links I've searched don't seem to cover how Powershell interacts with managing
    a Server 2012 R2 machine and cover things like scripting, etc. Also, I want to know how would one study IPv6 since this is also important to the exam.

    Hi Matthew,
    For IPV6 you can read:
    " http://technet.microsoft.com/en-us/library/dn610908.aspx  " 
    The best way to study PowerShell is to practice with PowerShell (i.e. Configure the Server Core). This is what I did. :)  Good Luck 
    Greets,
    Kenan
    P.s. : " Training Guide: Installing and Configuring Windows Server 2012 " is a good book that can help you for preparing for 70-410 exam 

  • Powershell and DB2

    Hi -
    I'm wondering if anyone has had any luck/experience with getting DB2 command file scripts to run via Powershell?
    In addition, I have a situation where I need to query two different DB2 databases for information.  First database has a list of customers that use a GUID for their identification.   I would like to run a Powershell/DB2 script to dump the
    list of customers to a .CSV file.
    I then need to hop over to another server and would like to run another Powershell/DB2 script that basically reads the .CSV file with list of customers and executes against another table on current server and matches the customer GUID identification against
    the GUID's in the current DB2 tables.    If these two databases where on the same servers, I could probably do a JOIN or something, but since they're not -- I have do to this mickey-mouse routine.
    Anyway, if anyone has any ideas, it would be greatly appreciated.   Trying to match up GUIDs to determine what customer is what is no fun and very tedious.
    I didn't write this software, do don't blame me! ;-)

    I've done a little with DB2 and powershell, the trick is to open the DB2 prompt, and then run powershell, that will allow you to run db2 commands in powershell.. if you run powershell and then db2, it doesn’t work...
    im not sure you really need that, you could probably just use ODBC or some other .NET database method.
    I've almost been able to rip the provider out of the a DB2 service pack so that I can run queries remotely. I've done it, just not sure exactly how I did it so I cant provide steps yet.
    very interested in the work youve done here.  do you have an update on this?

  • How to add calendar enries to all users in organization using powershell and EWS.

    I am one of the exchange admins for our organization.  Every year, we publish academic calendar data to all faculty and staff calendars.  We recently updated and migrated from Exchange 2003 to Exchange 2010 which, of course, desupported MAPI and
    ADO.  The processes we previously used had to be re-written using Exchange Web Services API (EWS).  Because I find that powershell is easy to work with, I wanted to integrate the calendar dispersal using powershell.
    Having not found much help online using the EWS .NET library in powershell for this purpose, I decided to share my code:
    # Bulk load calendar entries script
    # Description:
    # Script used to deploy Academic Calendar entries to all Exchange account calendars
    # Prerequisites:
    # Service account must have ApplicationImpersonation ManagementRoleAddisgnment
    # New-ManagementRoleAssignment -Name:impersonationRole -Role:ApplicationImpersonation -User:<srv_account>
    # Usage:
    # .\academicCalendar.ps1 calEntries.csv
    # Where calEntries.csv = list of calendar entries to add
    Param ([string]$calInputFile = $(throw "Please provide calendar input file parameter..."))
    $startTime = Get-Date
    $strFileName = "<path to log file>"
    if(Test-Path $strFileName)
    $logOutFile = Get-Item -path $strFileName
    else
    $logOutFile = New-Item -type file $strFileName
    # Load EWS Managed API library
    Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
    # Load all Mailboxes
    $exchangeUsers = Get-Mailbox -ResultSize Unlimited | Select PrimarySmtpAddress
    # Load all calendar Entries
    # Input file is in the following format
    # StartDate,EndDate,Subject
    # 8/29/2011,8/30/2011,First Day of Fall Classes
    $calEntries = Import-Csv $calInputFile
    # Setup the service for connection
    $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
    $service.Url = new-object System.Uri("https://<CAS_server_URL>/ews/exchange.asmx")
    $service.Credentials = new-object Microsoft.Exchange.WebServices.Data.WebCredentials("<service_account>","<password>","<domain>")
    $totalCount = $exchangeUsers.Count
    $currentCount = 0
    Write-Output "Exchange Version: $service.RequestedServerVersion"
    Write-Output "Mailbox Count: $totalCount"
    # Add message to log file
    $timeStamp = Get-Date -Format "MM/dd/yyyy hh:mm:ss"
    $message = "$timeStamp -- Begin Calendar Deployment `n"
    $message += "Total Exchange Accounts: $totalCount"
    Add-Content $logOutFile $message
    # Perform for each Mailbox
    $error.clear()
    foreach($mailbox in $exchangeUsers)
    $currentCount++
    if($mailbox.PrimarySmtpAddress -ne "")
    # Output update to screen
    $percentComplete = $currentCount/$totalCount
    Write-Output $mailbox.PrimarySmtpAddress
    "{0:P0}" -f $percentComplete
    # Setup mailbox parameters for impersonation
    $MailboxName = $mailbox.PrimarySmtpAddress
    $iUserID = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress,$MailboxName)
    $service.ImpersonatedUserId = $iUserID
    # Indicate which folder to work with
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar)
    $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderid)
    # For each entry in the input file
    $error.clear()
    foreach($entry in $calEntries)
    # First check to make sure the entry is not already in the calendar
    # use a calendarview object to pull the entries for the given date and make sure an entry with the same subject line doesnt already exist
    $cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView([System.DateTime]($entry.StartDate),[System.DateTime]($entry.EndDate))
    $cvCalendarview.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $frCalendarResult = $CalendarFolder.FindAppointments($cvCalendarview)
    $entryFound = $False
    foreach ($appointment in $frCalendarResult.Items)
    if($appointment.Subject -eq $entry.Subject)
    $entryFound = $True
    # If entry was found, then skip this entry
    if($entryFound)
    $entryFound = $False
    else # Create the appointment object and save it to the users calendar
    $appt = New-Object Microsoft.Exchange.WebServices.Data.Appointment($service)
    $appt.Subject = $entry.Subject
    $appt.Start = [System.DateTime]($entry.StartDate)
    $appt.End = [System.DateTime]($entry.EndDate) #For AllDayEvent, end date must be after start date
    $appt.IsAllDayEvent = $True #Set event as "All Day Event"
    $appt.LegacyFreeBusyStatus = "Free" #Make sure free/busy info shows user as "free" rather than "busy"
    $appt.IsReminderSet = $False #Make sure reminder is not set to remind the user of the event
    $appt.Save([Microsoft.Exchange.WebServices.Data.SendInvitationsMode]::SendToNone)
    if($error)
    $timeStamp = Get-Date -Format "MM/dd/yyyy hh:mm:ss"
    $message = $timeStamp + "...Exception Occurred while processing Save for: `n"
    $message += " Account: " + $MailboxName + "`n"
    $message += " Subject: " + $entry.Subject + "`n"
    $message += " Exception: " + $error[0].Exception + "`n"
    Add-Content $logOutFile $message
    $error.clear()
    if($error)
    $error.clear()
    else
    $message = "" + $MailboxName + "`t Success! `n"
    Add-Content $logOutFile $message
    Write-Output $currentCount
    $endTime = Get-Date
    $duration = New-TimeSpan $startTime $endTime
    $totalMin = $duration.TotalMinutes
    # Build and send email notification upon completion
    $body = "The Calendar deployment has completed. `n `n "
    $body += "Start Timestamp: $startTime `n "
    $body += "End Timestamp: $endTime `n "
    $body += "Duration: $totalMin min `n "
    $body += "Exchange accounts affected: $currentCount `n"
    $smtpServer = "<mysmtpserver>"
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $msg = new-object Net.Mail.MailMessage
    $msg.From = "<from_email_address>"
    $msg.To.Add("<to_email_address>")
    $msg.Subject = "Calendar Deployment"
    $msg.Body = $body
    $smtp.Send($msg)
    # Add closing message to log file
    $timeStamp = Get-Date -Format "MM/dd/yyyy hh:mm:ss"
    $message = "Accounts affected: $currentCount"
    Add-Content $logOutFile $message
    $message = "$timeStamp -- Completed in $totalMin min."
    Add-Content $logOutFile $message
    Please let me know if you think I can make any performance modifications.
    Daniel
    --Edit-- I have updated the script for Exchange 2010 SP1, also added logging, error checking and email notifications.  This new script also checks first to make sure the appointment doesn't already exist before adding it.  (To prevent multiple
    entries of the same event... Note: This check, although necessary in my opinion, is very time consuming.)

    Hi Daniel
    I am trying to add addition propertires like TV, Copier etc. to Room Mailbox in Exchange 2010 using following commands:-
    [PS] C:\Windows\system32>$ResourceConfiguration = Get-ResourceConfig
    [PS] C:\Windows\system32>$ResourceConfiguration.ResourcePropertySchema+=("Room/Whiteboard")
    Upper two commands run fine but following command gives error:-
    [PS] C:\Windows\system32>Set-ResourceConfig -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
    The term 'Set-ResourceConfig' is not recognized as the name of a cmdlet, function, script file, or operable program. Ch
    eck the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:19
    + Set-ResourceConfig <<<<  -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
        + CategoryInfo          : ObjectNotFound: (Set-ResourceConfig:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    I also tried with space after set but still getting error:
    [PS] C:\Windows\system32>Set -ResourceConfig -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
    Set-Variable : A parameter cannot be found that matches parameter name 'ResourceConfig'.
    At line:1 char:20
    + Set -ResourceConfig <<<<  -ResourcePropertySchema $ResourceConfiguration.ResourcePropertySchema
        + CategoryInfo          : InvalidArgument: (:) [Set-Variable], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
    Pl advise the solution at [email protected] . I got this help from
    http://zbutler.wordpress.com/2010/03/17/adding-additional-properties-to-resource-mailboxes-exchange-2010/

  • Compare two text files in Powershell and if a name is found in both files output content from file 2 to a 3rd text file

    Is it possible using PowerShell to compare the contents of two text files line by line and if a line is found output that line to a third text file?
    Lets say hypothetically someone asks us to search a text file named names1.txt and when a name is found in names1.txt we then pair that with the same name in the second text file called names2.txt
    lets say the names shown below are in names1.txt
    Bob
    Mike
    George
    Lets say the names and contents shown below are in names2.txt
    Lisa
    Jordan
    Mike 1112222
    Bob 8675309
    Don
    Joe
    Lets say we want names3.txt to contain the data shown below
    Mike 1112222
    Bob 8675309
    In vbscript I used search and replace commands to get part of the way there like this
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("testing.txt", ForReading)
    strText = objFile.ReadAll
    objFile.Close
    strNewText = Replace(strText, "Mike ", "Mike 1112222")
    Set objFile = objFSO.OpenTextFile("testing.txt", ForWriting)
    objFile.WriteLine strNewText
    objFile.Close
    That script works great when you know the name you are looking for and the correct values. Lets say someone gives you a list of 1000 employees and says import these names into a list in the correct format and one sheet has the correct names only and
    the other sheet has lots of extra names say 200000 and you only need the 1000 you are looking for in the format from names2.txt.

    Sure,
    Here's a simple one:
    $names1 = "C:\names1.txt"
    $names2 = "C:\names2.txt"
    $names3 = "C:\names3.txt"
    Get-Content $names1 | ForEach-Object {
    $names1_Line = $_
    Get-Content $names2 | Where-Object {$_.Contains($names1_Line)} | Out-File -FilePath $names3 -Append
    This basically just reads $names1 file, line by line, and then read $names2 file line by line as well.
    If the line being evaluated from $names2 file contains the line being evaluated from $names1 file, then the line from $names2 file gets output to $names3 file, appending to what's already there.
    This might need a few more tinkering to get it to perform faster etc depending on your requirements. For example:
    - If either $names1 or $names2 contain a lot of entries (in the region of hundreds) then it will be faster to load the whole content of $names2 into memory rather than opening the file, reading line by line, closing and then doing the same for every single
    line in $names1 (which is how it is currently works)
    - Make sure that your comparison is behaving as expected. The .Contains method always does a case sensitive comparison, this might not be what you are after.
    - You might want to put a condition to ignore blank lines or lines with spaces, else they'll also be brought over to $names3
    Hopefully this will get you started though and ask if you have further questions.
    Fausto

  • Powershell and Outlook 2007, trying to delete messages in a folder older than date

    I was hoping to get a powershell script that would do the following
    1) Connect to outlook 2007
    2) Go to Mailbox folder (not an inbox subfolder) called 'Processes'
    3) Delete all email from that folder older than 3 days old
    I did some searching, I have found very useful things like how to empty a deleted items folder.  I can even display all messages in that folder using this script snippet.  But whenever I try to filter it down to email older than 3 days old, it blows up on me.  I was attempting to use a | Where-Object pipe to reduce it and there are thousands of messages in that folder.
    $outlook = New-Object -ComObject Outlook.Application
    $olFolderInbox=6
    $n = $outlook.GetNamespace("MAPI")
    $f = $n.GetDefaultFolder($olFolderInbox)
    $mailbox = $n.Folders.Item($f.Parent.Name)
    $folder = $Mailbox.Folders.Item("Processes")
    $folder.Items
    #Clean out any open connections
    $outlook = $n = $f = $mailbox = $folder = $null;

    I thought I might offer another solution for this.  I came across this post looking to do the same, but I found it didn't always delete messages.  Based on some other information on another site I was able to come up with a modified version.
    The two other sites I referenced were:
    http://gallery.technet.microsoft.com/ScriptCenter/en-us/966637b9-0b70-41c0-99d0-4647a89da70a
    http://msdn.microsoft.com/en-us/library/bb220369%28office.12%29.aspx
    ----Script----
    #Name of folder to access.  You can specify subfolders by using FolderName\Subfolder
    $folderPath = "FolderName"
    #Filter older than 7 days
    $olderThan = (get-date).AddDays(-7)
    #Set format of date to use
    $dateFormat = "g" # This will base on time to do just date choose "M/dd/yyyy"
    #Create filter
    $sFilter = "[LastModificationTime] < `'$($olderThan.tostring($dateFormat))`'"
    $outlook = New-Object -ComObject Outlook.Application
    $olFolderInbox=6
    $n = $outlook.GetNamespace("MAPI")
    $f = $n.GetDefaultFolder($olFolderInbox)
    $mailbox = $n.Folders.Item($f.Parent.Name)
    $folders = $mailbox.Folders
    #Navigate to the proper folder
    foreach ($folderName in $folderPath.split("\"))
      $folder = $folders.Item($folderName)
      $folders = $folder.Folders
    $Items=$folder.items
    $FilteredItems = $Items.Restrict($sFilter)
    for ($i = $FilteredItems.Count; $i -gt 0; $i--) {
        Write-Host "Deleting $($FilteredItems.Item($i).Subject)"
        $FilteredItems.Item($i).Delete()
    #Clean out any open connections
    $outlook = $n = $f = $mailbox = $folder = $folders = $Items = $FilteredItems = $null;

  • Powershell and Client Object Model - no error thrown if user is added more than once to same site or group

    Hello All -
    I am trying to add a user to a SharePoint site using PowerShell like below:-
    New-SPUser -UserAlias MyDomain\jan20a -Web http://SPServer/sites/MySite
    If I execute the above more than once, SharePoint does not throw that user already exists or something. This is not the same behavior in AD/Exchange PowerShell cmdlets.
    Also, even the client object model behaves the same way.
    Another interesting thing I noticed, I tried to remove a user from group in which the user was not part of it at all and still no error..!!
    Looks like SharePoint does not care of invalid input and just ignores it.
    Can anyone please confirm this and also the reason behind it ?

    It's not really invalid input, since the user exists and that is how SharePoint behaves (will behave same way in browser).  Try to input a user that and misspell the name, e.g. say you didn't have a MyDomain\Jan21a, then try to use same script above,
    only with invalid data.  It will bark at you.  Or try using a web that it cannot find, one that does not exist.  You'll get what I like to call, the red badge of courage if you enter invalid data.
    you can test that sharepoint will let you enter a user twice in the browser, and nothing bad comes from it.  Powershell is just unable to tell that the user was not in the site, when you removed it the second time. 
    Hope that confirms it, if it does please mark this reply accordingly.  thanks
    Stacy Simpkins | MCSE SharePoint | www.sharepointpapa.com

  • How do I bulk upload documents using PowerShell and extract metadata from file name?

    I have a requirement to upload a bunch of documents into a document library. Based on the content type, the rules of updating the metadata is different...the one giving me trouble is to extract the metadata from the file name. If I have a file name like
    "part1_part2_part3.pdf" how do I extract part1, part2, part3 and tag each document being uploaded into SharePoint, using PowerShell? I have searched and have not been able to find anything to get me started.
    Has anyone done this before? Or is there a blog I can take a look at? Thanks
     

    You will have to write a PS script encompassing this logic.
    Read files from the folder using
    Get-Item cmdlet
    Determine the content type based on the path or filename.
    Split the file name to extract the tag names.
    If the metadata fields in the content type is a managed metadata field, check whether the term exists and set it.
    Updating SharePoint Managed Metadata Columns
    with PowerShell
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Excel with powershell and this big problem of locale

    Hi Folks, I'm getting C R A Z Y with this Excel/Powershell Stuff...
    MY display language is EN
    My input language is fr_CH
    the following code : 
    function Invoke([object]$m, [string]$method, $parameters)
    $m.PSBase.GetType().InvokeMember(
    $method, [Reflection.BindingFlags]::InvokeMethod, $null, $m, $parameters,$ciUS)
    $ciUS = [System.Globalization.CultureInfo]'fr-CH'
    $objExcel = New-object -com Excel.Application
    $objExcel.visible = $True
    $ci = [System.Globalization.CultureInfo]'fr-CH'
    $objWorkbook = Invoke $objExcel.Workbooks Add
    $objWorksheet = $objWorkbook.Worksheets.Item(1)
    $objWorksheet.Cells.Item(1,1).FormulaLocal = "A value in cell A1."
    Invoke $objWorkbook SaveAs "C:ScriptsTest.xls" > $null
    Invoke $objWorkbook Close 0 > $null
    $objExcel.Quit()
    throw me the error : 
    Exception calling "InvokeMember" with "6" argument(s): "Object does not match target type."
    At line:3 char:1
    + $m.PSBase.GetType().InvokeMember(
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : TargetException
    You cannot call a method on a null-valued expression.
    At line:11 char:1
    + $objWorksheet = $objWorkbook.Worksheets.Item(1)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    Basically this happend when you have english Excel with non english locale.
    My OS is in english but my Keyboard is in French-Swiss.
    Please help me I'm getting crazy...
    MCITP Enterprise Administrator / Server Administrator

    This might be helpful.
    http://dmitrysotnikov.wordpress.com/2008/02/22/powershell-help-broken-on-localized-versions-of-windows/
    The problem seems to be that PowerShell v1 for Windows Vista and PowerShell v2 CTP for all systems are storing the language neutral (English) help system in the en-US subfolder of the PowerShell folder.
    On a localized versions of Windows, PowerShell seems to be looking for a subfolder with its own locale (e.g. de-DE for Germany, ru-RU for Russia, and so on) and does not fail over to en-US if the folder is not found.
    RESOLUTION
    Apply the language pack for your language so your local version of help gets added to the system.
    If the language pack is not available, copy or rename the en-US folder to match your Windows locale. To learn your locale run the following command in the PowerShell prompt:
    [System.Globalization.CultureInfo]::CurrentUICulture
    Thanks Azam When you see answers please Mark as Answer if Helpful..vote as helpful.

  • Powershell and Outlook Issues

    So my ultimate goal is to export emails after a specific length of time as a .msg and then upload them to sharepoint for archival purposes.
    My issue is all the examples I find never seem to work for me. I use PowerGUI for my ISE, I have powershell 2.0 and Outlook 2007 SP3
    So for example, when I try something very simple according to the scripting guy
    Reference, I try this line of code:
    [Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.Outlook") | out-null
    [enum]::GetNames("Microsoft.Office.Interop.Outlook.OlDefaultFolders")
    This should list the enums used to point to the different folders in outlook....here are some of them:
    olFolderDeletedItems
    olFolderOutbox
    olFolderSentMail
    olFolderInbox
    olFolderCalendar
    olFolderContacts
    olFolderJournal
    When I run it, either PowerGUI or straight in the console I receive the following error:
    Cannot convert argument "0", with value: "Microsoft.Office.Interop.Outlook.OlDefaultFolders", for "GetNames" to type "System.Type": "Cannot convert the "Microsoft.
    Office.Interop.Outlook.OlDefaultFolders" value of type "System.String" to type "System.Type"."
    At C:\Users\clayman\AppData\Local\Temp\ceb3eca9-5cf1-4dd2-92aa-c2c29d3ca438.ps1:2 char:17
    + [Enum]::GetNames <<<< ("Microsoft.Office.Interop.Outlook.OlDefaultFolders")
    + CategoryInfo : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
    Truth be told, no matter what sample I try they all fail, for instance try and run this function (yet another scripting guy article)
    Function Get-OutlookInBox
    Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
    $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
    $outlook = new-object -comobject outlook.application
    $namespace = $outlook.GetNameSpace("MAPI")
    $folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
    $folder.items |
    Select-Object -Property Subject, ReceivedTime, Importance, SenderName
    And this one fails with:
    Add-Type : Could not load file or assembly 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dep
    endencies. The system cannot find the file specified.
    At C:\Users\clayman\AppData\Local\Temp\51f81593-6a0f-4261-9888-5499432508e7.ps1:3 char:10
    + Add-Type <<<< -AssemblyName "Microsoft.Office.Interop.Outlook" | Out-Null
    + CategoryInfo : NotSpecified: (:) [Add-Type], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.AddTypeCommand
    Exception calling "GetDefaultFolder" with "1" argument(s): "Value does not fall within the expected range."
    At C:\Users\clayman\AppData\Local\Temp\51f81593-6a0f-4261-9888-5499432508e7.ps1:8 char:39
    + $folder = $nameSpace.getDefaultFolder <<<< ($olFolders)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation
    If I change:
    Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook" | Out-Null
    To:
    [Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Interop.Outlook") | Out-Null
    The first error goes away, but the second one remains. What the heck am I doing wrong?
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

    Hi,
    How about change
    $folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
    to
    $folder = $namespace.getDefaultFolder($olFolders.olFolderInBox)
    Please test it.
    Regards,
    Yan Li
    TechNet Subscriber Support
    If you are
    TechNet Subscription
    user and have any feedback on our support quality, please send your feedback
    here.
    Cataleya Li
    TechNet Community Support

Maybe you are looking for

  • 1.4.1 plugin not working?

    I have deployed Java applets on IE5/6 with plugin versions 1.3.x up until 1.4.0_01 without any problems. Recently I upgraded to 1.4.1 (what does FCS stand for?) and now applets deployed in a JAR file fail to load and start altogether. I use the plugi

  • Error msg: "Config message not received after 45 seconds"

    I have developed a simple stateless session bean. After being called once, the following is output to the log: Thu Jan 04 18:15:46 CST 2001:<I> <RJVM> Signaling peer 3978882810638278829C198.171.129.36 gone: weblogic.rjvm.PeerGoneException: - with nes

  • Volume problem with Music Player on N95

    Hi all, I am puzzled with a problem I'm having with my N95. The problem appeared after I performed an upgrade on the phone.  The thing is that the right side Volume keys do not work when using the Music player. I know the keys work since the zoom is

  • Colors not saving correctly when image is saved, how can I fix this?

    Hi! I've been a photoshop user for my newish photography business since this past summer. I honestly still have a lot to learn, but thankful my images have always been spot on, until now...you see, I recently discovered that when I open my png or jpe

  • Creating multiple instances of JTextField

    Hy, I have a JtextField and a JButton. Depending on the value inserted in the JtextField, when I click on the JButton, I want a new window to open and create multiple instances of JTextField. I tried to use a for loop, but how do I differentiate amon