Translate

Thursday, September 15, 2016

Command to connect to scvmm from powershell

For scvmm 2012

Import-Module 'C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1'

$username = "xxx"          
$password = "yyy"
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

Get-VMMServer –Computername "sssss" -TCPPort 8100 -Credential  $credentials


For scvmm 2012 r2

Import-Module 'C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1'

The rest is the same

Sunday, May 1, 2016

Windbg download location

Get windbg by installing windows debugging tools for Windows 10

https://msdn.microsoft.com/en-us/windows/hardware/hh852365.aspx



When you run the install just pick Debugging Tools for Windows



























Once you install the debugging tools you will find windbg at

C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe

Another way to get windbg is by installing Windows driver kit.

https://msdn.microsoft.com/en-us/windows/hardware/hh852365.aspx

This Windows driver kit install includes windbg which works for

Windows 10
Windows 8.1
Windows 8
Windows 7
Windows Server 2016 Technical Preview
Windows Server 2008 R2

Once you install Windows driver kit, you will find windbg at 

C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\windbg.exe
and
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe

Tuesday, January 19, 2016

Powershell log all commands

If you want to log every single powershell command, run on your machine , including the ones run through C# code, one way to do it is to upgrade to powershell 5.

Once you install powershell 5 all you need to do is to update a registry key to turn it on

HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription








































Here is the powershell script to do this

function Enable-PSTranscription 
{  
    [CmdletBinding()]  
    param(  
        $OutputDirectory,  
        [Switch] $IncludeInvocationHeader  
    )  

    ## Ensure the base path exists  
    $basePath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription"  

    if(-not (Test-Path $basePath))  
    {  
        $null = New-Item $basePath –Force  
    }

    ## Enable transcription  
    Set-ItemProperty $basePath -Name EnableTranscripting -Value 1

    ## Set the output directory  
    if($PSCmdlet.MyInvocation.BoundParameters.ContainsKey("OutputDirectory"))  
    {  
        Set-ItemProperty $basePath -Name OutputDirectory -Value $OutputDirectory  
    }

    ## Set the invocation header  
    if($IncludeInvocationHeader)  
    {  
        Set-ItemProperty $basePath -Name EnableInvocationHeader -Value 1  
    } 
}

Enable-PSTranscription  -OutputDirectory 'C:\PowershellLogs'



To enable more detailed logging run this powershell command below after you performed the above steps

function Enable-PSScriptBlockLogging 
{  
    $basePath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging"  

    if(-not (Test-Path $basePath))  
    {  
        $null = New-Item $basePath –Force  
    }
   
    Set-ItemProperty $basePath -Name EnableScriptBlockLogging -Value "1" 
}


Enable-PSScriptBlockLogging