Saturday, December 13, 2014

Check for updates

 

Going through the Installed Updates list to check for a specific update that might or might not mess things up can be tedious using appwiz.cpl

Introduced in Powershell version 4 we have a new cmdlet for this purpose that come in handy.

Show list of all installed hotfixes
/> get-hotfix

Show if a specific update is installed:
/>get-hotfix -id "kb2843630"

 

References:
http://technet.microsoft.com/en-us/library/hh849836.aspx – syntax

Friday, December 12, 2014

Users cant create subsites with publishing template

Overview:
Funny thing happend the other day…
Site migrated from sharepoint 2010 to 2013. Certain groups can’t create subsites using Publishing template. They really want to…
Owners and members of constructor group can work fine.
Groups are using custom permission level.

Symptoms:
- Creating subsite with publishing or publishing with approval workflow results in :
              - EventID 4965 – Web Content Management – Couldt initate … properties
              - Server Error in ‘/’ Application – Runtime error
              - ULS throws errors when trying to create.
- Works for members of owner or constructor group.
- Works when creating a non-localized default format publishing site.
- Works when creating Team Site

clip_image002

clip_image004

Solution:
- Added Apply Themes and Border, Apply Style Sheets permission for the custom permission levels
- Added the relevant groups with read permissions for the /devicechannels list on each Site Collection.

clip_image006

Lessons learned:

- Devicechannels is a new feature of sp2013, permissions aren’t added automaticly if using custom groups, permissions levels and allowing for custom css.

References:

http://meandmysharepoint.blogspot.se/2014/03/runtime-error-when-creating-sharepoint.html -

Thursday, December 04, 2014

Cachehost is null

We're getting error Cachehost is null when trying to start Distributed Cache or removing the service with remove-spdistributedcacheserviceinstance

First of all verify these settings
- Windows Firewall have AppFabric Caching Service (TCP-Out) enabled on servers running DistributedCache
- Verify DistributedCache ports open between servers running Distributed Cache : 22233-22236 and Ping/Echo
- Verify following ports for AppFabric to talk sufficiently: 445, 139,135
- Can’t start Distributed Cache from the Central Admin
- Verify server and Active Directory talking ok.
- Verify DNS working

Verify status of Cachecluster. Is AppFabric and Sharepoint Server talking ok?
- Script : compareDCvsAppFabric-------
Add-PSSnapin microsoft.sharepoint.powershell


$instancename = "SPDistributedCacheService name=AppFabricCachingService"
$DC = get-spserviceinstance |where-object {($_.service.tostring()) -eq $instancename }
write-host "Sharepoint says..."
$DC |select typename, status,id,server |format-table

Use-CacheCluster
write-host "AppFabric says...."
Get-CacheHost |format-table

Result: Something is not ok. Sharepoint says fours servers and AppFabric says two. If same servers are reporting on both DC and AF then the problem is elsewehere.
image

Solution:
Remove the serviceinstance from the missing servers and add them again.
Script below removes serviceinstance from the computer the script runs from!
---------script: forceremovedistcache.ps1 --------------
Add-PSSnapin microsoft.sharepoint.powershell

$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName –and ($_.server.name) -eq $env:computername}
$serviceInstance
write-host "Deleting instance $serviceinstance.id"
$serviceInstance.Delete()

write-host "Adding distributed cache..."
Add-SPDistributedCacheServiceInstance
write-host "Done"

Scenario 2: The other way around. AppFabric says other stuff than sharepoint.
Solution:  Remove the host from the cluster.
----script: remove host from cluster ----
Add-PSSnapin microsoft.sharepoint.powershell
$cachehost =  $env:computername

Use-CacheCluster
Get-CacheHost
Unregister-CacheHost -hostname $cachehost -ProviderType SPDistributedCacheClusterProvider -connectionstring "<INSERTREGVALUE1>"
Add-SPDistributedCacheServiceInstance

Where regvalue1 is found : HKLM\SOFTWARE\Microsoft\AppFabric\V1.0\Configuration\ConnectionString  (remove “;enlist=false” from the string)

And then try to add distributed cache again.

Lessons learned:
- In a locked down environment make sure all relevant Distributed Cache ports are open before adding the service to server.
- AppFabric and Distributed Cache is not the same thing! Appfabric is a windows service while Distributed Cache is a sharepoint service instance. They don’t always agree! Make sure they’re talking!

References:

Sunday, November 23, 2014

Powershell and firewalls

Finally with Windows 8.1 and Server 2012 we have some new cmdlets that make managing firewall-rules much easier. Hopefully we can now put netsh to the everlasting rest.

Example script – blockapps.ps1

$rulename = "BlockSomething"
$appPath = "D:\temp\Myprogram.exe"
New-NetFirewallRule -displayname $rulename -Direction Outbound -Program $appPath -action Block

 

References:

http://technet.microsoft.com/en-us/library/jj554908.aspx – cmd syntax

Tuesday, October 21, 2014

Disable loopback on a website

If you need to access a sharepoint webapplication from the actual sharepointserver and you can’t seem to be able to authenticate properly. Then it’s possible a loopback issue. This is a slightly more proper way to do it. Still not recommended on a productionenvironment, but when in a tight spot, reach for the hammer. HKEY_LM\System\CCS\Control\LSA\MSV1.0 New Multi-string value Named: BackConnectionHostNames = sharepoint.mycompany.com  and /> iisreset /noforce   References:

http://blogs.technet.com/b/sharepoint_foxhole/archive/2010/06/21/disableloopbackcheck-lets-do-it-the-right-way.aspx

Tuesday, October 07, 2014

Powershell and xml

For future reference
script to read properties from a xml file and update specified values.
More of a proof of concept than any real world usage.
Good for any cocktailparty
----------------xmllooptest.ps1 ---------
$path = split-path -parent $MyInvocation.MyCommand.Definition
$inputfile = $path + "\myinputfile3.xml"
[xml]$xmlinput = (Get-Content $inputFile)

write-host $xmlinput.main.configuration.name" is my value"
write-host "Server is:"$xmlinput.main.configuration.server
write-host "Result : "$xmlinput.main.configuration.result


Write-host "Looping sites..."
$sites = $xmlinput.main.sites.site
foreach ($site in $sites)
{
    write-host "-----"
    write-host $site.name
    write-host $site.property
    if ($site.name -match "my site 2")
    {
    $site.property = "New property for site2"
    }
    write-host $site.property
   
}
$xmlinput.save($inputfile)
-----------------------eof-----------------
----------------- myInputfile3.xml------------


 
    myserver
    Wyoming
    Testing
 

 
   
      my site 1
      My even newer property
   

   
      my site 2
      New property for site2
   

 
--------------------eof--------------

Wednesday, June 18, 2014

Translate Windows error messages

Ive searched for this one for a while.

http://www.microsoft.com/Language/en-US/Emt.aspx
Translates localized Microsoft error message to english easier troubleshooting


Tuesday, May 27, 2014

Sharepoint Organisation information

Some guiding documents that are enlightning

http://sharepoint.mindsharpblogs.com/Bill/archive/2010/04/02/Organizing-Information-in-SharePoint-Server-2010.aspx – Great post about the cost and putability of document management.

http://office.microsoft.com/en-us/sharepoint-server-help/governance-101-best-practices-for-creating-and-managing-team-sites-HA101847542.aspx – Governance and site-management

http://www.ietf.org/rfc/rfc5013.txt – The Dublin Core Metadata Element Set. A standard for tagging documents.

https://www.nothingbutsharepoint.com/sites/eusp/Pages/16-ways-to-get-your-users-actually-using-SharePoint-properly.aspx – 16 ways to get your users actually using sharepoint properly

A few nifty commandments

To check version on farm, when fighting schema-issues while migrating

/>get-spfarm |select name,buildversion

image

To check correlation id when an unexpected error has occurred

/> get-splogevent | ?{$_.Correlation -eq "CORRELATION ID"} | select Area, Category, Level, EventID, Message |Format-List

To convert users from windows-based to claims-based on a migrated webapplication.

/>convert-SPWebApplication -Identity "https://portal:80 -To Claims –RetainPermissions

References:

http://ittechnotebook.blogspot.se/2013/07/how-to-find-real-error-in-sharepoint.html

http://www.wictorwilen.se/sharepoint-2013-claims-is-the-new-black

http://www.wictorwilen.se/Post/How-Claims-encoding-works-in-SharePoint-2010.aspx

http://www.windowsecurity.com/articles-tutorials/authentication_and_encryption/Claims-Based-Identity-What-does-Mean-You-Part1.html

Monday, May 19, 2014

Change default value on a choice column

To get a choice column with multiple selections to allow default values with multiple selections a calculated value is needed.

Note that this is mostly used in a Foundation environment where Terms are not allowed.

In the Default value field give formula: =";#Offer;#Deal;#" where Offer and Deal is valid column choices.

image

image

References:

http://sharepoint.stackexchange.com/questions/8281/is-it-possible-to-set-multiple-default-values-for-a-checkbox

Friday, May 16, 2014

Crashed site

A customer intranet died the other morning. The is what happend.

First user notifies of error while trying to access.

image

I start to look into it.

- First issue. Low/none diskspace. Frees up so its workable. This does nothing for the site. Tries restart to no avail.

- Checks all IIS-sites and Application Pools. A lot of pools are stopped. Starts these up, but not difference.

- Notices that patches been applied the previous night. Server starts warning for diskspace soon after. Ok so maybe a patch requires psconfig. Runs this but are greeted with error: Failed to initiate the upgrade sequence…. Method not found ‘void Microsoft.Sharepoint.WorkflowServices.Iworkflowservice.upgrade….

image

searching for this error doesn’t give much. Tries to uninstall the workflow manager services for this seems to related. the workflow 2013 mananger has given some ache in the past and isn’t used anyways. This gives nothing.

Tries to access Central Administration and curiously this works to certain degree. Until tries to access Service Application then it throws iWorkflowServices errors again.

image

Looks deeper into the logs and finds issues with the patches being applied.

image

Ok, so maybe a patch was trying to be applied but got stuck on the diskissue and landed in some unfinished state?

Tries to download the latest updates to see if this is an issue. There is some, but it takes alot of time.

Checks the size of the culprits Kb2863829. Turns out this mother is 827MB, no wonder it takes time. AND the patch requires and psconfig run after completion!

image

Let the update run through and then runs psconfig again. Though this failes on the Task 8 in the first run (Failed to create sample data) another run let it finishes.

Now everything works again!

What to take with us from this experience?

Always have 10-20GB free space on the sharepointserver!

References:

http://support.microsoft.com/Kb/2863829

http://social.msdn.microsoft.com/Forums/en-US/e5644dc3-3849-46fe-aa38-460e9f9d7bc2/error-in-configuration-wizard-after-installing-sharepoint-2013-service-pack-1?forum=sharepointadmin

Friday, April 25, 2014

Shrink transaction log

When transaction log has grown to size that is too big to take backup, or space just isn’t available AND the database just isn’t that important that it should drag all others to lag-hell this might be done to solve the issue.

Note that there is a point to transaction files. If the database is so important that you can’t loose a minuts worth of transactions its really a necessary feature. But if that need isn’t there, the recovery mode could easily be changed to Simple to avoid the risk of losing space on an old server and therefore halting critical applications.

But here it is anyways.

  1. Change recovery mode to Simple on the overgrown database.
  2. Run query: dbccshrinkfile (mydatabase_Log,0)
  3. Change recovery mode to Full again to restore the logging.

If the transaction logs grows, its usually because their isn’t a real backupsolution running for the database. Use maintenance jobs or stored procedures if a real one isn’t available.

Thursday, April 24, 2014

Can’t create maintenance plans

For some security reason these are disabled on SQL Server 2008-2012 on some occasions. Might be a servicepack disables it. But maintenance plans are a nice tier 2 security precaution.

Get thrown this error when trying to create a maintenance plan

image

Ran following query on victimserver to solve it.

image

Wednesday, April 23, 2014

Manage stored wireless networks in W8

Microsoft, in all their wisdom, have removed the Manage my wireless network option that was available on the wireles interface in Windows 7 and earlier. So, how to we manage it now?

See stored wireless profiles

/> netsh wlan show profiles

Delete a profile

/> nets wlan delete profile name=mynetwork

To show saved information, including key

/> netsh wlan show profiles name=mynetwork key=clear

 

Or to use the gui-way

Charms>PC Settings>Networks>Connections>WiFi>Manage known networks

But only thing you can do from here is see the name and forget the network, so learn the cli way.

References:

http://social.technet.microsoft.com/Forums/windows/en-US/ac80d8ec-21ad-4d44-9a0c-c8777f861db7/windows-8-manage-wireless-networks?forum=w8itpronetworking

Wednesday, March 26, 2014

Where’s my search dude?

I made a customer installation of Sharepoint Foundation 2013 recently. Naturally I used the latest Slipstreamed Microsoft package with Service Pack 1.

Sure everything looks fine at first, but after first site collection is up and running I notice that the searchbox is missing. Sure, maybe a glitch, runs new full crawl, but nothing changes. Tries to create a new search center site, site creator throws a sorry my way.

image

Tries to create my own custom page and add the search webpart and get another fun message “Common Language Runtime detected an invalid progam”.

image

Ok, maybe language is an issue, installs localization pack for swedish and creates new site collection. Same error.

After searching for information on the issue someone makes me aware of the fineprint of Slipstreampackaged Foundation downloadpage

image

First time that field contained any relevant information!

Searching on forums shows a few MS-cases that all indicates that this is an issue which will be fixed in the April CU. So we have to wait I tell the customer, looking like a noob cause they don’t want to put in the extra time for a reinstallation sans SP1.

But today I found an update that solved the issue!  Curiously not by googling but in my rssfeeds…

Hero of the day is: KB2760625 March 2014 PU for SharePoint Foundation 2013

Note the package is claiming to aimed at Sharepoint Enterprise Server but it worked nicely on my Foundation.

References:

http://support.microsoft.com/kb/2760625

http://www.microsoft.com/en-us/download/details.aspx?id=42268

http://www.sharepointblogs.be/blogs/vandest/archive/2013/12/10/sharepoint-foundation-2013-broken-search-experience.aspx

http://blogs.technet.com/b/stefan_gossner/archive/2014/03/20/an-important-fix-for-sharepoint-foundation-2013-sp1-has-just-been-released.aspx

Thursday, March 06, 2014

Shared Mailbox mail sent folder

In Exchange 2013 with Outlook 2010 client, mail sent dont land in the corresponding sent folder.

For example, If John has access to shared mailbox Info@contoso.com, mail he sends with info as sender will land in his personal sent folder. This makes John and John collegues confused.

Solution:

  1. Make sure KB24591115 is installed, from 2010 so most likely. http://support.microsoft.com/kb/2459115
  2. Add this registry value on Johns computer/session
  3. Key: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Preferences
    Name: DelegateSentItemsStyle
    Type: DWORD
    Value: 1

    Or run FixIt on https://support.microsoft.com/kb/2181579

    References:

    https://support.microsoft.com/kb/2181579

    http://support.microsoft.com/kb/2459115

Tuesday, March 04, 2014

The simplicity of Promoted Links

Ever gazed upon the startpage of a Sharepoint Team Site and wondered how you could make your own Get Started panel?

image

Its simpler than it looks.

  1. Create a List of type Promoted Links
  2. Create Items on the list, add images if you under Background Image Location
  3. Add list as a webpart
  4. Done

image

image

Wednesday, February 26, 2014

Hide page title

Before to the left, after to the right
imageimage
Solution:
  1. Create txt file named removepagetitle.txt
  2. Enter :
  3. <style>
    .ms-core-pageTitle{Display:none !Important;}
    </style>
  4. Upload removepagetitle.txt to your site, for example Site Assets\CodeSnips\
  5. On page insert Content Editor, link your removepagetitle.txt
  6. Title disappears.
Obviously this also can be inserted to a central css and be rid of without pesky webparts, but nice if you want some options.

When using the oslo-masterpage code below seems to do the trick.
<style> #pageContentTitle { display: none !important; } </style>
References:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/47f10498-d72a-446d-9b26-840fb89f9142/how-to-hide-site-title-in-sharepoint2013?forum=sharepointgeneral

Friday, February 21, 2014

Extract year from date in SPD

Create Sharepoint Workflow 2010

1. Create 2 variables, wholedate and year

2. Define functions

Set Variable:wholedate to currentitem:start time   (return field as ISOFormatted)

  then copy 4 characters from start of variable:wholedate(output to:variable:year)

  then log variable:year to the workflow history list

image

image

References:

http://weblogs.asp.net/wesleybakker/archive/2010/12/28/get-datepart-in-sharepoint-designer-workflow.aspx

Thursday, February 20, 2014

Quick Steps in Lists

Often neglected, I find this hidden feature useful for making no-code solutions.
Its a bit messy though.
image
To create, go to SPD > List > Custom Action > Choose where the button should appear. Its not completly obvious in my opinion so I’ve listed the name and where they’ll appear below.
When creating the manually from SPD, we got more alternatives than when creating a Quick Step directly from the Webgui. For example we now can add a webaddress, which can lead anywhere, either a local place on the sharepoint or somewhere offsite.
image
Examples:
ListItem – Shows on the submenu on the listitem.
image
Edit Form – Shows in the Edit Form.
image
Display Form – shows in the Display Form.
image
New Form – shows in the New Form
image
View – Shows in the List Ribbonmenu
image
From this custom actions we can also configure where the link should appear to some degree by modifying the Ribbon Location ID
image
For example, the Display Form button lands in the Manage container per default.
image
If I want to move this icon to right part of the form, I can change the .Manage. to .Actions.
 image

References:
http://blog.furuknap.net/sharepoint-2010-ribbon-locations - nice overview of where we can place our buttons.







Wednesday, February 19, 2014

Disable java warnings

Java keeps blocking my stuff.

Figure that Procurve switches doesn’t come with signed applets.

Nothing worked while trying to access a procurveswitch after latest Java-update. Wouldn’t even get the option of running anyways.

To get it running:

Java Control Panel > Advanced> Security > Mixed Code > Disable Verification

image

Now its only one warning about unsigned stuff, haven’t managed to kill this one yet.

I usually prefer to avoid java on my machines, but when it comes to Procurve-switches its unfortunately required.

 

image

What happend with Low?

References:

http://gdgtry.com/2010/05/disable-javas-new-security-warning/

http://service.parachat.com/knowledgebase/273/I-see-a-Do-you-want-to-run-this-application-security-warning-with-Java-7-Update-10.html

http://jaxenter.com/unsigned-java-applets-hit-by-security-update-46755.html

Deploy MSI-package from GPO

To deploy msi package to from GPO.

1. Create GPO DeployPackage

a. User Configuration>Policies>Software Settings>Software Installation

b. Create new package, choose msi to deploy. Must be located on a shared folder that has read permissions for authenticated users (to include all domain computers).

c. Choose Published

d. Choose newly created package, Change Deployment>Deployment Type to Assigned and Check Deployment options>Install this application at logon

2. Deploy this GPO to an OU where the User object is located.

3. GPUpdate /force on both server and client.

4. If all works, the client will notice the policy and request a restart.

5. Package should deploy as soon as logged in.

image

Friday, February 14, 2014

Hide columnheaders on a webpart

To hide headers on a webpart
  1. Add a contenteditor webpart
  2. Edit HTML-source
  3. Paste
  4. <style>
    .ms-viewheadertr {
    DISPLAY: none
    }</style>
  5. Columns should disappear at once. Hide webpart from form.


References:
http://reyazuddinkhan2.blogspot.se/2013/03/hide-column-header-in-sharepoint-list.html
http://www.sharepointdiary.com/2013/03/content-editor-web-part-hidden-property-disabled.html cant hide when using publishing pages.
http://forums.bitwiseglobal.com/forum/sharepoint/hiding-content-editor-web-part/


Thursday, February 13, 2014

Word with values from Document Library Columns

 

  1. Upload Wordtemplate to documentlibrary
  2. Create Site Content Type
  3. Advanced Settings > Enter url of wordtemplate in documentlibrary
  4. Associate site content type with your documentlibrary
  5. Edit Word Template in documentlibrary
  6. In Word, Insert > Quick Parts > Document Property >
  7. Choose your list columns, should be at the bottom.Place in wordtemplate at your leisure.
  8. Now, when creating new template from this Site Content Type the field will be automaticly populated with the columns values.

Using folders as metadata-masters

A handy feature to use when bulk-uploading documents to Sharepoint is the “Default Column Value”. This feature shines when using folders.

For example, say $user wants to upload 2000 images to an assetlibrary and wants to tag these with managed metadata values, 3 of them for a third of the lot and something else for the rest. Managed metavalues can’t be edited in datasheet view when using multiple values so this might take some time for $user.

In this case $user could create three folders in the assetlibrary and from Library Settings>Column Default Values > Folder  change the values as $user wants.

image

Now all documents copied to this folder, even from ExplorerView, will get these default values. Unless manually specifying something else.

The cool thing is that when the values have been set, $user can copy the images elsewhere in the documentlibrary and the metadata will still be attached. So folders can be used as a transitstation for settings metavalues. Or just be presented with a flat structure in the view.

References:

http://social.technet.microsoft.com/wiki/contents/articles/11301.sharepoint-2010-bulk-metadata-tagging.aspx

Friday, February 07, 2014

Alerts not working for some users

Nuisance mayor.

A client had an issue with alerts not working for some users.

image

Sorry something went wrong. The following users do not have an e-maildress specified:

Turned out email issues overall for these users.

Tried did not succed.

  • Restarted Server
  • User Profile Sync new full
  • Removed failing users profile from User Profiles and did a new full sync.
  • Changed settings for email in AD, synced verified changes where coming through. Changed back, still same issue.

Success:

Tried running />get-spuser –web http://myserv | select userlogin,displayname,email 

Noted that email was missing for the difficult users. Now why is that?

Verifed that Replicable was activated on the User Profile Properties settings for the emailfield. All looked good.

Fixed it by running :

/>$myuser = get-spuser –web http://myserv |?{$_.displayname –like “*myuser*”}

/> set-spuser –identity $myuser –web http://myserv –SyncFromAD

To identify accounts with no email

/> get-spuser –web http://myserv | where {-Not $_.email} |select userlogin,email

To output add |export-csv myusers.txt

Conclusions:

External client weren’t so interrested in putting in more time to figure out exactly what was wrong in the first place. New users for example are adding their email field from the AD without any issues. The problem users were added to the site prior to defining the email attribut in the AD so that may have been an issue aswell. Im still fidning it odd that the email were looking like they should in the User profile Services but not when using powershell. might be that the user profile service is making a lookup in the AD when browsing the profiles, but can’t be sure .

Solution found. Cause unknown. ill revisit this later.

References:

http://social.technet.microsoft.com/wiki/contents/articles/13771.troubleshooting-steps-for-sharepoint-alert-email-does-not-go-out.aspx

http://www.sharepointdiary.com/2012/02/sharepoint-alerts-not-working-troubleshooting-checklist.html#ixzz2aSvOz3hB

http://patrikluca.blogspot.se/2008/06/alerts-not-working-for-some-users-on.html

http://blogs.msdn.com/b/tehnoonr/archive/2009/10/13/sharepoint-alerts-emails-don-t-work-on-some-vmware-systems.aspx?Redirected=true

http://www.stuartroberts.net/index.php/2013/07/10/user_profile_sync/#more-1488 – email not available efter moving user

http://sharepointpratik.blogspot.se/2013/03/the-following-users-do-not-have-email.html

http://blogs.technet.com/b/steve_chen/archive/2009/11/20/alerts-in-sharepoint-troubleshooting-moss-wss.aspx

http://blogs.technet.com/b/harikumh/archive/2008/05/25/troubleshooting-alerts.aspx

http://www.harbar.net/archive/2011/02/10/account-deletion-and-sharepoint-2010-user-profile-synchronization.aspx

http://blogs.msdn.com/b/russmax/archive/2010/03/20/sharepoint-2010-provisioning-user-profile-synchronization.aspx

http://community.rightpoint.com/blogs/viewpoint/archive/2010/08/26/the-truth-about-how-daily-sharepoint-alerts-actually-work.aspx

http://social.technet.microsoft.com/Forums/sharepoint/en-US/b671a6c8-3065-4299-b7be-d40e9c5d982b/alert-me-error?forum=sharepointgenerallegacy Tells us email must be added prior to adding user to sp.

http://social.technet.microsoft.com/Forums/sharepoint/en-US/7c3947b9-c675-444c-b325-23185282eb74/user-email-not-updating-with-sharepoint?forum=sharepointadminprevious

Wednesday, February 05, 2014

Schedule a powershell script

When certain task has run, its nice to be notified. since email function is deprecated in taskscheduler we have to pull out powershell.

image

1. Create the script

-------sendmail.ps1-----

param([string]$task)
$psemailserver = "smtp.mycompany.com"
$receiver = john.doe@company.com
$from = task@company.com
$subject = "Task has run"
$body = "Scheduled task $task has run. "
send-mailmessage -to $receiver -from $from -subject $subject -body $body
write-host "Mail sent for $task"
write-eventlog -logname Application -source "my script" -entrytype information -eventid 1 -message "$task has run"
------eof----

2. Create the call using Task Scheduler “powershell –file “c:\myfile\sendmail.ps1” “helloworld”

What the script does is take an input variable and sending an email using defined smtpserver in the script. When mail is sent, it also logs en event in the application eventlog with source “my script”. The param is optional, but helpful if you want more reusability.

The source needs to created the first time manually, or use an already existing source.

Create source “my script” in application

/>New-eventlog –logname application –source ”my script”

References:

http://blogs.technet.com/b/heyscriptingguy/archive/2013/06/20/how-to-use-powershell-to-write-to-event-logs.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

http://stackoverflow.com/questions/16426688/passing-a-variable-to-a-powershell-script-via-command-line

Thursday, January 30, 2014

Local SMTP with Sharepoint 2013

Sharepoint isn’t very flexible when it comes to email server.

Enter the local smtpserver.

  1. Install SMTPServer
  2. Configure SMTP-Service using IIS6.0 Management Tools
    1. Access>Relay image
    2. Delivery>Outbound Security>basic authentication image
    3. Delivery>Outbound Connection> Specify TCP port
    4. Delivery>Advanced image
    5. All OK.
  3. Configure Centralt Administration>Web Application> Outgoing email = myserver.mydomain.local

It should work immediatly. No need to reset IIS or restart the smtpserver.

Sometimes youre mailing servers you cant verify settings on. Then Gmail can be used to verify the mailflow.

For google

  • Basic Authentication = myaccount@gmail.com , pwd: mypassword, use TSL
  • Use TCP port 587
  • Smarthost = smtp.gmail.com

To check email flow on local server, drive:\inetpub\mailroot\queue folder can be monitored. When mail is sent from sharepoint ,it lands in this folder while contacting the smtpserver. When there’s a problem, the mail will be stuck here. In some situations it might be needed to empty this folder, then content in this folder can be deleted if the iisadmin service first is stopped.

/>stop-service iisadmin

/>start-service iisadmin

/>start-service smtpsvc

References:

http://blogs.technet.com/b/yashgoel-msft/archive/2012/10/26/configuring-outgoing-email-settings-in-sharepoint-with-gmail-smtp.aspx

Sunday, January 26, 2014

Excel datedif formula

Useful excelformula that is hidden from the common gui, but present in all version of excel.

To compare a date to today

=DATEDIF(A1,TODAY(),"d")
Outputs difference in days. Can also return in complete months, years and then some.




















D

Number of days

MNumber of complete months
Y

Number of complete years

YD

Number of days excluding years

MD

Number of days excluding months and years

YM

Number of months excluding years


Note that on Swedish systems formulas look like this instead:


image


Comma is replaced by semicolon for some reason.


References:


http://excel.datedif.com/


http://stackoverflow.com/questions/10928586/excel-calculate-the-date-difference-from-today-from-a-cell-of-7-6-2012-102642

Friday, January 24, 2014

Windows phone on Windows 8.1

While trying to copy files to my Lumia 520, my windows didn’t show the phone in my computer.

To solve this

1. Install Window Phone App

http://www.windowsphone.com/en-au/how-to/wp8/windows-phone-app-for-desktop

Why? I don’t know, this is supposed to work out of the box. But it might be an issue since Lumia 520 is a pretty cheap issue.

Or the issue might be that Metro-phone app stole the attention.

This is how its supposed to look: image

Now we can copy files like an usual folder.

Now, how do we do this wirelessly?

Thursday, January 23, 2014

Thumbs in Searchresults in SP2010

Was working from sharepointblogs.com instructions trying to get Thumbnails from an Assetlibrary to be displayed in an Searchresultspage, but couldnt get the thumbs to stick.

Finally I tried removing “contentypeforsearch.=’image’  frome the xsl-customizations and it started working right away. Somehow the images in my results wasn’t interpreted as images. Maybe the .jpg filetype needs to added manually or something.

In this case, its a Imagesearch result page so the results are always images.

It works, im happy. customer happy. Done.

Before:

<xsl:when test="contenttypeforsearch[. = 'Image'] and contentclass[. = 'STS_ListItem_851']">

After:

<xsl:when test="contentclass[. = 'STS_ListItem_851']">

References:

http://blogs.msdn.com/b/david/archive/2011/06/27/previewing-audio-and-videos-in-sharepoint-2010-search-results.aspx

http://www.sharepointblog.com/2010/11/image-content-type-thumbnails-in-2010.html – the moneyshot

http://www.ableblue.com/blog/archive/2008/08/30/sharepoint-image-search-part-2/ – a bit old, still generally informational.

http://www.novolocus.com/2008/05/22/showing-thumbnails-in-search/

http://blogs.technet.com/b/anneste/archive/2008/11/25/mystery-solved-crawled-properties-in-sharepoint-part-5.aspx – details regarding how the crawling properties works.

Wednesday, January 22, 2014

Remove borders from View Style Boxed

 

For a case im using a link-list on a startpage. Reasons include making it easier for endusers to manage their own used applications, without rummaging around with tables etc.

For this reason the boxed view style served me well.

image

The box-borders gave an ugly look. To remove these, add content Editor webpart and insert

<style>
TD.ms-stylebox {
    BORDER:0 !important;
}</style>

Effect should be immediate.

image

Tuesday, January 21, 2014

Re-arm trial Server 2008+

While doing labs, applying snapshots and whatnot the licensekey sometimes disappears or you just dont wanna waste an activation on a testmachine.

To re-arm a Server triallicense

Elevated Cmd-prompt

Check current licenselevel

/>slmgr.vbs –dli

Extend the evalution period with another 60 days

/>slmgr.vbs –rearm

Server can be rearmed up to 3 times giving you a total of 240 days.

References:

http://support.microsoft.com/kb/948472

http://blogs.technet.com/b/johnbaker/archive/2009/08/29/extending-your-evaluation-activation-grace-period-on-windows-server-2008-and-2008-r2.aspx

Monday, January 20, 2014

Shared folders using ps

To create a shared folder using powershell

New-SmbShare –Name ShareName –Path C:\LocalFolder

To get permissions on existing

Get-SmbShareAccess –Name ShareName

 

References:

http://blogs.technet.com/b/josebda/archive/2012/06/27/the-basics-of-smb-powershell-a-feature-of-windows-server-2012-and-smb-3-0.aspx

Thursday, January 16, 2014

Filtrera listvyer med localized Sharepoint

För en lokaliserad version av Sharepoint 2010 så används även svenska på de logiska funktionerna. Det är väl ok, när man kommer till ro med att det går att använda åäö på funktioner “Date=Datum,Year=År,Month=Månad etc”. Det som är knepigare att få grep och är varför de bytt ut skiljetecknen!

För att få fram en första dagen i en månad baserat på ett datumfält så funkar i Engelsk version denna:

=DATE(YEAR([Due Date]), MONTH([Due Date]), 1)
Motsvarande funktion på Svensk version:
=DATUM(ÅR(visning);Månad(visning);1)
Notera att “,” är utbytt emot “;” på svensk version. 

Så för att filtrera en listvy baserad på vilken månad som är angivet i ett fält kan följande metod användas.



  1. Skapa kolumn Visning(datumtyp)

  2. Skapa kolumn MonthEnd(beräknad) : formel =DATUM(ÅR(visning);Månad(visning);1)  output=dateimage[6]

  3. Skapa kolumn MonthStart(beräknad) : formel=DATUM(ÅR(visning);månad(visning)+1;1)-1   output=date

  4. Skapa vy,


    1. filtrera med MonthStart är mindre än eller lika med [I dag]

    2. Filtrera med MonthEnd är större än eller lika med [I dag]

imageimage


image


References:


http://iwillsharemypoint.blogspot.in/2012/03/sharepoint-list-view-of-current-month.html

http://kalsing.blogspot.in/2006/02/sharepoint-list-group-by-month.html

http://blog.pentalogic.net/2009/11/howto-filter-items-current-calendar-month-view-sharepoint/