Monday, June 12, 2017

TSQL Pivot Example


DROP table #temp

create table #temp
(
  Rack varchar(200),
  Sensor varchar(200),
  Diff int
)

INSERT INTO #TEMP VALUES ('R1','TEMP',20)
INSERT INTO #TEMP VALUES ('R1','HUMID',20)
INSERT INTO #TEMP VALUES ('R2','TEMP',25)
INSERT INTO #TEMP VALUES ('R2','HUMID',22)
INSERT INTO #TEMP VALUES ('R3','TEMP',19)
INSERT INTO #TEMP VALUES ('R3','HUMID',10)

SELECT * FROM #temp

SELECT Rack, [TEMP],[HUMID]
FROM #temp
PIVOT (MAX(Diff) FOR Sensor IN ([TEMP],[HUMID])) AS X

Thursday, May 18, 2017

Windows Update


dism /online /get-packages

Get-WmiObject -Class "win32_quickfixengineering" | Select-Object -Property "Description", "HotfixID", @{Name="InstalledOn"; Expression={([DateTime]($_.InstalledOn)).ToLocalTime()}}

$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object Title, Description, Date, @{name="Operation"; expression={switch($_.operation){1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}}

Friday, April 21, 2017

Like button for Outlook email

Recently my colleague was asking is there a like feature in Outlook.  I showed him the new Icon insert option.  It helped, but he was just looking for a one click solution.

Here the OneClick solution.  You need to have the below macro and introduce this as a new button in outlook menu!

Now you can start liking the emails.

Sub InsertLike()
    'Dim objDoc As Word.Document, objSel As Word.Selection
    On Error Resume Next
   
    '~~> Get a Word.Selection from the open Outlook item
    Set objDoc = Application.ActiveInspector.WordEditor
   
    Set objSel = objDoc.Windows(1).Selection
   
    '~~> Type Relevant Text
    'objSel.TypeText "Sorry cannot help"
    objSel.InlineShapes.AddPicture FileName:="https://hubblecontent.osi.office.net/ContentSVC/Content/Download?provider=MicrosoftIcon&fileName=ThumbsUpSign.svg" _
        , LinkToFile:=False, SaveWithDocument:=True
       
    Set objDoc = Nothing
    Set objSel = Nothing
End Sub

Teams PowerShell

 The PowerShell helps to get quick meta data around Teams. Install-Module -Name MicrosoftTeams Connect-MicrosoftTeams Get-TeamAllChannel...