Search This Blog

Thursday, November 19, 2015

Sharepoint Redirect to Notes://

I couldn't get my Sharepoint admin to add support to another link type so I created an html file to store in my Sharepoint's Site Assets as a redirector. Then I could embed the shortcut to the html redirector in any Sharepoint content.

HowToStartNotes.html ==========================================
<!DOCTYPE html> <!-- app001/srv/mycompany 10.10.10.23 app002/srv/mycompany 10.10.02.54 app003/srv/mycompany 10.10.132.132 app004/srv/mycompany 10.10.214.03 Not everyone has access via the Domino server's name in their region's DNS. So, replacing the link's server name with the server IP makes it globally accessible. --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>How To Link</title> <meta http-equiv="refresh" content="0;URL='Notes://10.10.132.132/1234567890123456/12345678901234567890123456789012/12345678901234567890123456789012'" /> </head> <body> <p>This page is an automatic link to to the <a href="Notes://10.10.132.132/1234567890123456/12345678901234567890123456789012/12345678901234567890123456789012"> How to start Notes</a> article in the <a href="Notes://10.10.132.132/1234567890123456"> Notes How To database</a>. <br> <br> Contact the Helpdesk if it is not working as needed. </p> </body> </html>

Wednesday, July 22, 2015

Domino Mail Stats with Powershell

I was helping a project team implement ZL Tech's (zlti.com) archiving with folks from Honda (Honda.com) and ViewPointe (Viewpointe.com) and found myself getting metrics every couple of hours. Which got really annoying pretty fast... And, so the following bit of code helped me to let other folks do the same as needed.
Have Fun! : )

The Output...

PS D:\data\scripts\ps-notes> ./MailStats.ps1
Start: 13:09:57.0831

Host            Drive    Size GB    Free GB
=============== ===== ========== ==========
AMnotes01          F:     150.00      28.19

   Mailbox            Size MB  Doc Count
   =============== ========== ==========
   mail1.box           12,336          6
   mail2.box            4,884          4
   mail3.box            4,727          4
   mail4.box            4,651          4
   --------------- ---------- ----------
   Totals              26,598          4

Elapsed Time: 00:00:17.0125

The Code...
## MailStats.ps1
## First Code 07:05:20.0415
## initial runtime 00:00:48.0165
## 
$dtStart = (get-date)
"Start: "+($dtStart.Hour.ToString()).PadLeft(2,"0")+":"+($dtStart.Minute.ToString()).PadLeft(2,"0")+":"+($dtStart.Second.ToString()).PadLeft(2,"0")+"."+($dtStart.Millisecond.ToString()).PadLeft(4,"0")
$StartPath = Get-Location

## Vars to set
$LocalDataDir = 'C:\Program Files (x86)\IBM\Lotus\Notes\Data' ## your local Notes data dir
$DominoServiceName = 'UserSMTPgw01/SRV/AM/MyCompany' ## your Notes/Domino Server
$HostName = 'AMnotes29' ## the host name that the Domino service runs on
$HostDataDir = 'f$\notes\data\' ## the rest of the unc path to the Domino services' data dir 
$HostDataDrive = 'F:' ## drive where the Domino services' data dir is on 

$UNCMailboxPath = '\\'+$HostName+'\'+$HostDataDir+'mail*.box'
$MailBoxes = Get-ChildItem -Path $UNCMailboxPath

Set-Location $LocalDataDir
$Notes = New-Object -ComObject Lotus.NotesSession
$Notes.Initialize()

$HostMBDisk = Get-WmiObject Win32_LogicalDisk -ComputerName $HostName | where {$_.DeviceID -eq 'F:'} | Select-Object Size,FreeSpace

Write-output ""
Write-Output "Host            Drive    Size GB    Free GB"
Write-Output "=============== ===== ========== =========="
Write-Output  ( $HostName.PadRight(15)+' '   `
               +$HostDataDrive.PadLeft(5)+' '    `
               +("{0:N2}" -f ($HostMBDisk.Size/1GB)).ToString().PadLeft(10)+' '   `
               +("{0:N2}" -f ($HostMBDisk.FreeSpace/1GB)).ToString().PadLeft(10))
Write-output ""
Write-Output "   Mailbox            Size MB  Doc Count"
Write-Output "   =============== ========== =========="

$TotSize = 0
$TotDocs = 0

foreach ($mailbox in $MailBoxes) {
   
   $dbMB = $Notes.GetDatabase($DominoServiceName, $mailbox.name.ToString(), 1)

   if ($dbMB -ne $null) {

      $colAllDocs = $dbMB.AllDocuments

      Write-output  ( "   "   `
                      +$mailbox.name.ToString().PadRight(15)+' '   `
                      +("{0:N0}" -f ($dbMB.Size/1MB)).ToString().padleft(10)+' '   `
                      +($colAllDocs.Count.ToString().padleft(10)))
      $TotSize = $TotSize + $dbMB.Size
      $TotDocs = $colAllDocs.Count

      $colAllDocs = $null

   } else {
         
      $strStatus = 'No Mailbox'

   }
      
   $dbMb = $null

}
Write-Output "   --------------- ---------- ----------"
Write-output  ( '   Totals          '   `
               +("{0:N0}" -f ($TotSize/1MB)).ToString().padleft(10)+' '   `
               +($TotDocs.ToString().padleft(10)))

Write-output ""

Set-Location $StartPath
$dtDiff = (New-Timespan -Start $dtStart -End (Get-Date))
"Elapsed Time: "+($dtDiff.Hours.ToString()).PadLeft(2,"0")+":"+($dtDiff.Minutes.ToString()).PadLeft(2,"0")+":"+($dtDiff.Seconds.ToString()).PadLeft(2,"0")+"."+($dtDiff.Milliseconds.ToString()).PadLeft(4,"0")
$TotSize = $null
$TotDocs = $null
$dbMB = $null
$Notes = $null
$StartPath = $null
$dtStart = $null

Sunday, June 7, 2015

Getting a Web Page with PowerShell

This is a patern to get a webpage. I sometimes work in a network accessing the internet through a proxy, So there is included a block where proxy creds are used.

GetWebPage.ps1
#http://learn-powershell.net/2011/02/11/using-powershell-to-query-web-site-information/
#http://stackoverflow.com/questions/571429/powershell-web-requests-and-proxies

Begin {
    $user = $env:username
    $url = "https://hereisasite.net"
    #$url = "http://google.com"
    $pwd = Read-Host "Password?" -assecurestring
    $account = new-object System.Net.NetworkCredential($user,[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd)), "")

    #$proxyAddr = (get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').ProxyServer
    #$proxy = new-object System.Net.WebProxy
    #$proxy.Address = $proxyAddr
    #$proxy.credentials = $account
    #$proxy.useDefaultCredentials = $true

    $web = New-Object System.Net.WebClient
    $web.Credentials = $account
    #$web.proxy = $proxy

    $flag = $false
}
Process {
    While ($flag -eq $false) {
        Try {
            $webpage = $web.DownloadData($url)
            $str = [System.Text.Encoding]::ASCII.GetString($webpage)
            $flag = $true
        } Catch {
             Write-host -fore Red -nonewline "Access down... "
             $str = "Nothing to see here... "
             $flag = $true
        }
    }
}
End{
    Write-Host $str
}

Thursday, March 5, 2015

Three.js - My First Three.js on canvas

My first Three.js app on canvas Just blow this test is there a spinning box?...

Is there a spinning box above this?
Found it! it's at the way at the bottom of the page. (I'll fix it soon)

Wednesday, February 25, 2015

Cool Maps

At least, I think they are cool...

Comment if you want anything added.

Live global air traffic   http://flightradar24.com/
Cyberthreat Real-Time Map   http://cybermap.kaspersky.com/
   I love the presentation. This is nice fish tank.
Live Attacks     http://map.ipviking.com/
   This one reminds me of the film War Games. "Would you like to play a game?"
Top daily DDoS attacks workdwide   http://www.digitalattackmap.com/
   Informative and clean.

Tuesday, February 10, 2015

Powershell - Active Directory User's Group List

All I wanted to do was to see a list a semi-readable list of the groups a client belongs to.

Get-ADUser am00000b
gives me a list of default values returned.
PS C:\WINDOWS\system32> get-aduser am00000b


DistinguishedName : CN=Lesley,OU=Users,OU=AM,DC=MyCompany,DC=com
Enabled           : True
GivenName         : Lesley
Name              : am00000b
ObjectClass       : user
ObjectGUID        : ffffffff-ffff-ffff-ffff-ffffffffffff
SamAccountName    : am00000b
SID               : S-1-5-21-999999999-999999999-9999999999-99999
Surname           : Phillips
UserPrincipalName : am00000b@am.mycompany.com


Get-ADUser am00000b -Properties * shows me all the AD properties associated with the user. (which you can do on your own). From there I can see the property I'm looking for... MemberOf . If you have a lot of groups assigned to the user, it may be truncated. And, it is not in any particular order. However, you can add MembersOf to the results with -Properties memberof
PS C:\WINDOWS\system32> get-aduser am00000b -Properties memberof


DistinguishedName : CN=Lesley,OU=Users,OU=AM,DC=MyCompany,DC=com
Enabled           : True
GivenName         : Lesley
MemberOf          : {CN=AMG-Heat-Users,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
                    CN=AMG_Internet_USERS,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
                    CN=RightFax,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
                    CN=APP-ATTConnect-stduser,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,...}
Name              : am00000b
ObjectClass       : user
ObjectGUID        : ffffffff-ffff-ffff-ffff-ffffffffffff
SamAccountName    : am00000b
SID               : S-1-5-21-999999999-999999999-9999999999-99999
Surname           : Phillips
UserPrincipalName : am00000b@am.mycompany.com


Passing that into a Select -ExpandProperty memberof gives the following result.
PS C:\WINDOWS\system32> get-aduser am00000b -Properties memberof | Select -ExpandProperty memberof
CN=APP-Heat-Users,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
CN=AMG-Internet-stdusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
CN=APP-RightFax-admusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com, 
CN=APP-ATTConnect-stduser,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Clarity-testuser,,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Clarity-stduser,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=IS-Level-1,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(Instant Message),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(email),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^PCAdm,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^DominoServer,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^RemoteControl,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(CompSec),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(Organizational Email),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(MySpace),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=IS-B-jo,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-SCCM,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^LocalDev,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-FAXServer,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Heat-stdusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-Smartcard-stdusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-AD-adm,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com


And, finally, to make it semi-readable pass in to a Sort-Object
PS C:\WINDOWS\system32> get-aduser am00000b -Properties memberof | Select -ExpandProperty memberof | Sort-Object
CN=^DominoServer,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^LocalDev,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^PCAdm,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=^RemoteControl,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-AD-adm,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-FAXServer,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-Internet-stdusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
CN=AMG-SCCM,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=AMG-Smartcard-stdusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-ATTConnect-stduser,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Clarity-stduser,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Clarity-testuser,,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Heat-stdusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=APP-Heat-Users,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com,
CN=APP-RightFax-admusers,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com, 
CN=IS-B-jo,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=IS-Level-1,OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(CompSec),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(email),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(Instant Message),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(MySpace),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com
CN=SecWebAccess(Organizational Email),OU=Global,OU=Groups,OU=AM,DC=MyCompany,DC=com


Most examples I found don't use the shorthand for the CN lookup, but rather use a -filter {CN -eq "am00000b"}. Which would look like this...
get-aduser -filter { CN -eq "am00000b" } -Properties memberof | Select -ExpandProperty memberof | Sort-Object