Thursday, January 16, 2014

Taskmanagement in powershell

My favorite commands tasklist and taskkill are getting old. Time to get on the powershell bandwagon now when xp is losing its supported-status.

For tasklist-like results

/>get-process |where-object {$_.processname –like msiexec}

Where msiexec is queried process

For taskkill-like results

/>stop-process –name notepad

Where notepad is process to be killed.

Also nice to have

/>restart-computer

Which is pretty obvious. Restart immediatly on default. Use with scheduler for more use.

References:

http://technet.microsoft.com/en-us/library/hh849837.aspx - restart-computer

http://technet.microsoft.com/en-us/library/ee177004.aspx - stop process

http://technet.microsoft.com/en-us/library/hh849781.aspx - stop process

http://technet.microsoft.com/en-us/library/hh849832.aspx - get process

http://www.powershellmagazine.com/2012/11/27/better-restart-computer-cmdlet-in-powershell-3-0/ - restart-computer enhancements in ps3.0

http://jrich523.wordpress.com/2012/11/28/using-powershell-schedule-job-to-reboot-a-computer/

Friday, January 10, 2014

Free up space in Windows 8

This is sort of up there in terms of freeing up space. A bit over the top for the ordinary users.
There is however a method of removing the install files for Windows features you don’t need. It goes like this:
/>dism.exe /online /disable-feature /featurename:sua /remove
But if you want to remove a lot of not needing features this could be tedious. enter powershell
------------flushfeatures.ps1-----------
foreach ($item in get-content featuresclean.txt)
{
write-host "Removing feature $item"
dism.exe /online /disable-feature /featurename:$item /remove
    }
-----------eof-------------
Where featuresclean.txt is a file where every line contains a feature to be flushed.
To get all windowsfeatures on the system in a single list it can be a bit tricky.
I solved it a bit rough bit
/>get-windowsoptionalfeature –online |? state –eq ‘disabled’ |export-csv output.csv
and then copied the relevant columns from the csv to featuresclean.txt
Really not recommended if you don’t know what your doing
References:
http://technet.microsoft.com/en-us/magazine/2007.04.powershell.aspx
http://blogs.technet.com/b/joscon/archive/2012/11/20/features-on-demand-in-windows-8-and-windows-server-2012.aspx
http://technet.microsoft.com/en-us/library/hh824822.aspx
http://www.howtogeek.com/174705/how-to-reduce-the-size-of-your-winsxs-folder-on-windows-7-or-8/

Tiny calender in SP 2010

Customer want a small calenderview. Like the one in Outlook.image

This can be achived using all built in tools with some css tinkering.

You need:

  • A calenderlist using a calenderbased view
  • A content editor web part

Steps:

  1. Insert webpart using calenderview
  2. Insert webpart content editor webpart (CEWP)
  3. Edit CEWP

<style>
.ms-acal-header TD {
    VERTICAL-ALIGN: top
}
.ms-acal-rootdiv TD {
    VERTICAL-ALIGN: top
}
.ms-acal-rootdiv TH {
    VERTICAL-ALIGN: top
}
.ms-acal-rootdiv {
    OVERFLOW: hidden; FLOAT: right; MARGIN-LEFT: 0px
}
.ms-acal-vitem {
    VISIBILITY: hidden; BACKGROUND-COLOR: #f2f2f2
}
.ms-acal-month-weeksel {
    WIDTH: 5px; VISIBILITY: hidden
}
.ms-acal-summary-dayrow TH {
    CURSOR: pointer; BORDER-TOP: #b6c5c6 0px solid; BORDER-RIGHT: #b6c5c6 0px solid; BORDER-BOTTOM: #b6c5c6 0px solid; BORDER-LEFT: #b6c5c6 0px solid; VISIBILITY: hidden; BACKGROUND-COLOR: #ced8d9
}
.ms-acal-month-top {
    WIDTH: 20px; BORDER-BOTTOM: #b6c5c6 1px solid; COLOR: #919649; PADDING-BOTTOM: 2px; TEXT-ALIGN: center; PADDING-TOP: 2px; PADDING-LEFT: 2px; PADDING-RIGHT: 2px
}
.ms-acal-summary-dayrow TH {
    CURSOR: pointer; BORDER-TOP: #b6c5c6 0px solid; HEIGHT: 0em; BORDER-RIGHT: #b6c5c6 0px solid; BORDER-BOTTOM: #b6c5c6 0px solid; BORDER-LEFT: #b6c5c6 0px solid; VISIBILITY: hidden; BACKGROUND-COLOR: #ced8d9
}
.ms-acal-summary-itemrow TD DIV {
    HEIGHT: 0px; WIDTH: 0px
}
.ms-acal-vlink IMG {
    VISIBILITY: hidden; MARGIN-RIGHT: 3px
}
.ms-acal-vlink A:hover {
   
}</style>

4. Save

Now this view will expand the row if there is an item on that week. Not so pretty, but itll work for this case.

  • Onhover on date the events of that day should be displayed
  • Date should be bold or different color if their is events on that day.

image

References:

http://www.sharepointgrind.com/Lists/Posts/Post.aspx?ID=19

http://blog.pathtosharepoint.com/2008/10/06/tiny-sharepoint-calendar-1/

http://erikswenson.blogspot.se/2013/04/small-calendar-for-sharepoint-2010-2013.html

Wednesday, January 08, 2014

Useful ps filters

To filter results from a powershell query where-object can be used.

For example to filter get-spserviceapplication by field typename

/>Get-spserviceapplication |where-object{$_.typename –like “Search Service”

will result in all objects that contains Search Service. Switch –like for –eq to more precise results.

To get specific field to a variable

/>$serviceid = Get-spserviceapplication |where-object{$_.typename –like “Search Service”  |select id

Simple but powerful.

References:

http://windowsitpro.com/powershell/where-object-filter-filters

Firefox Disable full screen warnings

To get rid of annoying full screen warnings in Firefox

image

  1. About:config
  2. Set Full-screen-api.approval-required to false.
  3. Restart Firefox

image

Tuesday, December 17, 2013

Autoend task Windows 8.1

More annoyances. When I choose reboot or shutdown windows timeouts and waits for the user to actually push end tasks. This happens on most of my W8 machines.

To shutdown these apps more brutally heres another reghack.

-----autoend.reg-------------

Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Control Panel\Desktop]
"AutoEndTasks"="1"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"WaitToKillServiceTimeout"="2500"

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

 

References:

http://www.anushand.com/2013/02/auto-end-tasks-windows-8-at-shutdown.html

http://www.reddit.com/r/windows/comments/1936nl/waiting_for_background_programs_to_close_how_do_i/

Saturday, December 14, 2013

Windows 8.1 and the mythical WinSxS

To see the actual size of the WinSxS folder in Windows 8.1

/>dism /online /cleanup-image /analyzecomponentstore

Backups and Cache is the actual space used by WinSxS

To cleanup the folder in Windows 8.1

/> dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
To do it on previous versions (to w7 or vista)
/>dism /online /cleanup-image /spsuperseded
After running this command its no longer possible to uninstall updates or servicepacks. But most people don’t and if you change your mind, you can always get the msi-package and still do an uninstall.
 


References:


http://technet.microsoft.com/en-us/library/dn251566.aspx


http://technet.microsoft.com/en-us/library/dn251565.aspx

Powershell and Uptimerobot

Uptimerobot can be quite tedious when you need to update many monitors at once. For example say you bought the license for Uptimerobot and n...