Compartilhar via


Update alerts by using Windows PowerShell (SharePoint Server 2010)

 

Aplica-se a: SharePoint Server 2010

Tópico modificado em: 2016-11-30

This article describes Invoke-AlertFixup, a Windows PowerShell advanced function used to update the Uniform Resource Locator (URL) of a Web application used in alert e-mails after a Web application address changes. It replaces the Stsadm updatealert operation that was available in the April 2008 release of the SharePoint Administration Toolkit. The advanced function is loaded by running a script of the same name.

For more information about advanced functions, see about_Functions_Advanced (https://go.microsoft.com/fwlink/p/?LinkId=196720).

To update URLs by using Windows PowerShell

  1. Verify that you meet the following minimum requirements:

  2. Copy the code from the Script Center (https://go.microsoft.com/fwlink/p/?LinkId=196687), and then paste it into a text editor, such as Notepad.

  3. Save the file, naming it Invoke-AlertFixup.ps1.

    Observação

    You must use the provided name or the script will fail, and you must save the file as an ANSI-encoded text file.

  4. On the Start menu, click All Programs.

  5. Click Microsoft SharePoint 2010 Products.

  6. Click SharePoint 2010 Management Shell.

  7. Change to the directory where you saved the file.

  8. At the Windows PowerShell command prompt, dot source the Invoke-AlertFixup.ps1 file by typing the following:

    . ./Invoke-AlertFixup.ps1
    

    Observação

    To dot source a script, type a dot (.) and a space before the script path. The dot sourcing feature lets you run a script in the current scope instead of in the script scope. When you run a script that is dot sourced, the commands in the script run as though you had typed them at the command prompt. For more information, see about_Scripts (https://go.microsoft.com/fwlink/p/?LinkId=239611).

    This script contains the Invoke-AlertFixup advanced function. Once the script is loaded to memory for the current Windows PowerShell session, Invoke-AlertFixup can be used like a Windows PowerShell cmdlet, for example:

    Invoke-AlertFixup -site <SiteCollURL> -oldurl <OldURL>
    

    Where:

    • <SiteCollURL> is the Site Collection URL seen in the ImmedSubscriptions table of the content database.

    • <OldURL> is the old URL of the site.

    Observação

    In order for Invoke-AlertFixup to work correctly, the URLs specified with the site and oldurl parameters must reside in the same site collection. This is necessary to allow proper updating of alerts in a specific zone. Alerts for each zone must be updated individually using the proper new zone URL to that of the original (old) zone URL.

  9. To display all alerts that would be updated using the Invoke-AlertFixup command, at the Windows PowerShell command prompt type the following syntax:

    Invoke-AlertFixup -site <SiteCollURL> -Oldurl <OldURL> -whatif
    

    Where:

    • <SiteCollURL> is the Site Collection URL seen in the ImmedSubscriptions table of the content database.

    • <OldURL> is the old URL of the site.

Example

Your company has a Web application that is configured with three zones, as shown in the following table.

Coho Winery zone mapping

Description URL Zone

Intranet

http://cohowinery

Default

Extranet

http://extranet.cohowinery.com

Extranet

Vendor

http://vendors.cohowinery.com

Custom

Your company merges with Coho Vineyard and changes its name to Coho Winery and Vineyard. Management wants to change the Intranet and Extranet zones to reflect the new name change. The following table displays the new zone configuration.

Coho Winery and Vineyard zone mapping

Description URL Zone

Intranet

http://cohovineyardandwinery

Default

Extranet

http://extranet.cohovineyardandwinery.com

Extranet

After the name of the Web application is changed and the alternate access mappings are updated, Invoke-AlertFixup should be run to update the e-mail alerts associated with the intranet and extranet sites, as follows:

Invoke-AlertFixup -site http://cohovineyardandwinery -oldurl http://cohowinery

Invoke-AlertFixup -site http://extranet.cohovineyardandwinery.com -oldurl http://extranet.cohowinery.com

Observação

No changes are made regarding the vendor site, as Coho Winery has decided not to change the name of the vendor portal.
For additional information about extranet scenarios, see Exemplo de design: implantação corporativa (SharePoint Server 2010).

See Also

Other Resources

Running Windows PowerShell Scripts
Resource Center: Windows PowerShell for SharePoint Server 2010