Friday, 22 January 2016

Displaying slide show on same monitor with PowerPoint 2013

  1. Click the Slide show ribbon bar
  2. Select the Window presentation option
  3. Hit F5

image

Wednesday, 13 January 2016

Extract job titles from AD using powershell

For a given list of userids in a file called users.txt use the following powershell command in the same directory


Get-Content users.txt | foreach {Get-ADUser -Identity $PSItem -Properties mail,title | select -Property mail, title} |Export-Csv users.csv

Or use this to find new starters in the organisation...

$lastWeek = (get-date).AddDays(-31);

Get-ADUser -Filter * -Properties Title, whenCreated, Description, LastLogonDate | ? whenCreated -gt $lastWeek | ? Description -Like 'London' | select Name, Title, whenCreated, DistinguishedName, LastLogonDate | fl



Note: For windows 7 desktop users you’ll need to install the active directory modules for powershell by following the installation steps here
https://www.microsoft.com/en-gb/download/details.aspx?id=7887
For all active directory attributes / propery names, see this link here
http://www.kouti.com/tables/userattributes.htm
Another way to have done it would have been usng SQL via a linked server
https://www.mssqltips.com/sqlservertip/2580/querying-active-directory-data-from-sql-server/
e.g.
SELECT     *
FROM OPENQUERY( ADSI,
    'SELECT samaccountname, mail, title, sn
     FROM ''LDAP://dc=companyname,dc=com''
     WHERE objectCategory = ''Person'' AND objectClass= ''user''
     AND userprincipalname = ''*'' AND mail = ''*'' AND SN = ''*''
         ORDER BY useraccountcontrol
      ')
      Where
      samaccountname= ‘myaccountloginname’

Wednesday, 6 January 2016

Powershell cruise control build output parser

<#
.Synopsis
   Write-XmlPathOutput processes all files in a directory for a given XPath expression and puts the results to .txt files of the same name
.EXAMPLE
   Write-XmlPathOutput -DirectoryPath DirectoryPath -XPath //*/project
.INPUTS
   DirectoryPath - the path to the directory
   XPath - the xpath you wish to use
.OUTPUTS
   .txt text files in the same directory
#>
function Write-XmlPathOutput
{
    [CmdletBinding(DefaultParameterSetName='Parameter Set 1',
                  SupportsShouldProcess=$false,
                  PositionalBinding=$false,
                  HelpUri = 'http://merrickchaffer.blogspot.com/',
                  ConfirmImpact='Medium')]
    [OutputType([String])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipeline=$true,
                   ValueFromPipelineByPropertyName=$true,
                   ValueFromRemainingArguments=$false,
                   Position=0,
                   ParameterSetName='Parameter Set 1')]
        [ValidateNotNull()]
        [Alias("p")]
        [String]
        $DirectoryPath = (Get-Location).Path,

        # xpath help description
        [Parameter(Mandatory=$false, ParameterSetName='Parameter Set 1', Position=1,
                    ValueFromPipeline=$true,
                   ValueFromPipelineByPropertyName=$true,
                   ValueFromRemainingArguments=$false )]
        [Alias("x")]
        [String]
        $XPath = "//*/project/@file"

    )

    Begin
    {
    }
    Process
    {
        if ($pscmdlet.ShouldProcess("Target", "Operation"))
        {
            $files = Get-ChildItem (Get-ChildItem $DirectoryPath\*.xml)
            if ($files -ne $null -and $files.Length -gt 0) {
               
                ForEach ($file in $files) {
                 
                  $OutFile = [string]::Concat($file.FullName, ".txt")
                 
                  Select-Xml -Path $file.FullName -XPath $XPath | Select -ExpandProperty Node | Out-File $OutFile

                }
            }

        }
    }
    End
    {
    }
}

Write-XmlPathOutput -DirectoryPath C:\temp -XPath "//*/project/@file"

Thursday, 31 December 2015

Great electrician

Spoke with these guys yesterday on their day off
http://www.checkatrade.com/RKBuilders/
image
and they still gave me great advice which helped me with some light fitting that I had spent the morning struggling with.
Can thoroughly recommend their services. Father and son team, and I spoke to the son, who really knew his stuff when it came to GU10 halogen downlight bayonet fitting.

Wednesday, 16 December 2015

Speech with windows powershell

Set-ExecutionPolicy Unrestricted -Force

<#
.Synopsis
   Allows you to speak on a remote computer
   Requires that you have run winrm qc on the remote machine
   or Enable-PSRemoting. And on the local machine you've changed
   Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value * -Force 
.DESCRIPTION
   Allows you to speak on a remote computer
.EXAMPLE
   Speak-Remote 1 "How are you today" REMOTE_PC
.EXAMPLE
   Speak-Remote -RemoteComputerName REMOTE_PC
#>
function Speak-Remote
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [string]
        $Times = (Read-Host "How many Times"),

        # Param2 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=1)]
        [string]
        $Message = (Read-Host "What should I say"),

        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=2)]
        [string]
        $RemoteComputerName
    )

    Begin
    {
    }
    Process
    {
        Invoke-Command -ScriptBlock {Param($msg, $n) Add-Type -AssemblyName System.Speech; $o = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer; $o.SelectVoice("Microsoft Zira Desktop") ; $y = 0; do { $o.Speak($msg);$y = $y + 1;} until ($y -eq $n) } -ComputerName $RemoteComputerName -ArgumentList $Message, $Times
    }
    End
    {
    }
}

Speak-Remote -RemoteComputerName REMOTE_PC