Make sure your Azure ARM VM’s are not a threat

The script below will deploy or un-deploy the Azure antimalware extension from all VM’s in a resource group. You need to ensure the anySettings and SqlSettings are correct for your world.

[cmdletbinding()]
param (
    $rgname="release4.11.0.1",
    [bool]$adding = $true
)
 
# Get-AzureVMAvailableExtension | fl -Property Publisher, ExtensionName
 
$location="north europe"
$extName="IaasAntimalware"
$extType="IaaSAntimalware"
$extPublisherName="Microsoft.Azure.Security"
 
 
$anySetting = @"
{
"AntimalwareEnabled": true, 
"RealtimeProtectionEnabled": true,
"ScheduledScanSettings": {
       "isEnabled": true,
       "day": 1,
       "time": 120,
       "scanType": "Quick"
       },
"Exclusions": {}
}
"@
 
$sqlSetting = @"
{
"AntimalwareEnabled": true, 
"RealtimeProtectionEnabled": true, 
"ScheduledScanSettings": {        
       "isEnabled": true, 
       "day": 1, 
       "time": 120, 
       "scanType": "Quick"  
       },        
       "Exclusions": {
             "Extensions": ".mdf;.ldf",
             "Paths": "D:\\;E:\\",
             "Processes": "excludedproc1.exe;excludedproc2.exe"    
             }
       }
"@
 
 
$allVersions= (Get-AzureRmVMExtensionImage -Location $location -PublisherName "$extPublisherName" -Type "$extType").Version
$versionString = $allVersions[($allVersions.count)-1].Split(".")[0] + "." + $allVersions[($allVersions.count)-1].Split(".")[1]
 
 
$vms = get-azurermvm -ResourceGroupName $rgname
 
$vms | % {
    $thisVm = $_
 
    $whichSetting="Any"
    $setting = $anySetting
 
    if($thisVm.Name -like "*-sql") {
        $setting = $sqlSetting
        $whichSetting="SQL"
    }
    if($adding) {
 
    write-host ("ADDING $whichsetting setting to " + $thisVm.Name)
 
    Set-AzureRmVMExtension `
            -ResourceGroupName $rgname `
            -VMName $thisVm.Name `
            -Name "$extName" `
            -Publisher "$extPublisherName" `
            -TypeHandlerVersion "$versionString" `
            -ExtensionType "$extType" `
            -Location "$location" `
            -SettingString "$setting"
    }
    else {
        write-host ("REMOVING FROM " + $thisVm.Name)
        Remove-AzureRmVMExtension -ResourceGroupName $rgname -VMName $thisVm.Name -Name "$extName"
    }
}

Search fix (Simple single server farm only)

I am constantly having issues with three things on SharePoint 2013 farms

  • Search
  • UP Synch
  • Managed metadata

So to search.  Often following a reboot the search admin screen will show one component or another in a non ideal state.  Red cross, Yellow warning triangle etc.

googling will show you many and various ways to fix some / all or none of these issues, re create index, flush SharePoint Caches, re provision Search host, and the list goes on and on and on…

For times when all these fail me, I have crafted this simple script to surgically take out a broken component and replace it with a shiney new one.  It is intended for single server with simple search topology and if you use it you are responsible for ensuring the code is fit for ‘your’ purpose.

I think the script is self explanatory.

 

[cmdletbinding()]
param (
    [Parameter(Mandatory=$true)]
    $component # Crawl, Admin, Query, Content, Analytics, Index
)
 
write-host "ONLY USE ON A SIMPLE, SINGLE SERVER FARM,  IF THIS IS THE CASE, COMMENT OUT NEXT LINE AND RE RUN"
break
 
# Grab the Search Service Instance
#
$Sinstance = Get-SPEnterpriseSearchServiceInstance -Identity $env:COMPUTERNAME
 
# Grab active topology
#
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
 
# Create a clone of active to work with
#
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active
 
# grab component giving us trouble
#
$problem = Get-SPEnterpriseSearchComponent -SearchTopology $clone | ? {$_.Name -like "$component*"}
$problem
 
# Remove troublesome component from clone
#
if($problem.GetType().ToString() -eq "System.Object[]") {
    $problem | Remove-SPEnterpriseSearchComponent -Identity $_ -SearchTopology $clone -Confirm:$false
}
else {
    Remove-SPEnterpriseSearchComponent -Identity $problem -SearchTopology $clone -Confirm:$false
}
 
switch($component) {
    "Crawl" {
        New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance $Sinstance
    }
 
    "Admin" {
        New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $Sinstance
    }
 
    "Query" {
        New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $Sinstance
    }
 
    "Content" {
        New-SPEnterpriseSearchContentProcessingComponent  -SearchTopology $clone -SearchServiceInstance $Sinstance
    }
 
    "Analytics" {
        New-SPEnterpriseSearchAnalyticsProcessingComponent  -SearchTopology $clone -SearchServiceInstance $Sinstance
    }
 
    "Index" {
        New-SPEnterpriseSearchIndexComponent  -SearchTopology $clone -SearchServiceInstance $Sinstance    
    }
 
    default {
        write-host "Dont understand" $component
    }
}
 
# Make clone active
#
Set-SPEnterpriseSearchTopology -Identity $clone
 
# Clear out Inactive topologies
#
get-SPEnterpriseSearchTopology -SearchApplication $ssa | ? {$_.state -ine "Active" } | Remove-SPEnterpriseSearchTopology -Confirm:$false

SharePoint 2013 Managed Metadata Service – Issue

This may happen to you, if it does this may help.

Deployed March public update to my farm, this caused the Managed Metadata service to not be able to connect from either central admin or a site collection site settings pages.

It claimed the service not running or app pool not started see your administrator, message in a red square box on termstore management pages ….

Now this is all working fine prior to March PU (I know it is true, I have check points I revert to and check) so this is very odd.

Well, you could just delete the MMS and re create your term stores manually ? well, no, some internal stuff in SharePoint used the unique id of terms and termsets internally, if you delete and recreate the MMS the terms and termsets will have new id’s so the internal plumbing will break.

So, in my case the PowerShell commands;

Export-SPMetadataWebServicePartitionData
Import-SPMetadataWebServicePartitionData

Still allowed me to access the MMS data (Really odd ?????) even though the SharePoint UI would not.

So;

  • Export the MMS to file, Something.cab on the app server
  • e.g Export-SPMetadataWebServicePartitionData -Identity “http://server.intranet.com” -Path “c:\software\mmd.out.cab” -ServiceProxy “Managed metadata service”
  • Delete the original MMS (Include data) in central admin
  • Recreate MMS with exactly same names and app pool in central admin
  • Copy exported CAB file to a share on the SQL box
  • Run the import on the app server
  • e.g. Import-SPMetadataWebServicePartitionData -Identity http://server.intranet.com” -Path “c:\software\mmd.out.cab” -ServiceProxy “Managed metadata service” -OverwriteExisting:$true

Chances are the import will fail, Make sure MMS service account has BULK ADMIN rights in SQL and in a multi server farm you must put the export file on your SQL box in a shared (everyone full control) folder, and on the app server refer to it via UNC in the import command.

Happy days, Metadata is back and seems internally to be good as new.

 

Screen recorder

I had to create a small video of some software I have been asked to write. Usually I would ask the client to come along and walk through the software with me. During that process I would take notes and feedback.

Back in the office I would implement the feedback and notes and this typically results in getting much nearer to the clients requirements than waiting till the software is complete before she sees the end result.

On this occasion I could not be in the same office as the client, I decided a small video of me demonstrating the software would be ideal and more or less replicate us being at the same desk.
I usualy use Snagit 9 for my screen capture requirements, turns out for some reason it fails to work properly on my windows 7 install, functions as you would expect but during capture the window you are capturing does not accept mose clicks. This makes it a bit tricky to capture any video.

I looked around for a recorder and came accross this
Total screen recorder website

Nice, small neat product, it does exactly what it says on the can. It costs less than £25.00. You cant go wrong with this package.

Here is the video I made, literally two clicks after installing the product. Video

You can see from this copy from their website how easy it is;
Total Screen Recorder is an easy-to-use video recording application with clean interface.
*Easy – Just two steps to start recording!
First, click the ‘Start’ button (The red button) to prepare for recording;
Second, drag your mouse to choose the area of your desktop to be recorded;
That’s All…
Recording video on your computer has never been so easy!
*Light – Low CPU & memory usage when recording

Total Screen Recorder uses low CPU and memory when recording so that it will guarantee a high quality recording video without affecting the running of other applications at the same.

*Powerful.
– Support 5 recording types: random region, specified window, full screen, fixed size, fixed region.
– Support recording audio sync from computer and microphone.
– Video/Audio codec parameter adjustable.
– Support hotkeys to start or stop recording.
– Support setting timer to start/stop recording automatically.
– Support customizing video file names.
– Support sneak recording mode.

Total Screen Recorder has met Microsoft testing requirements for compatibility with 32-bit and 64-bit Windows 7/Vista.

SPDatasource

Stolen from Chris O’Brien
His blog

<SPWebControls:SPDataSource
	runat="server"
	ID="dsPersonTitles"
	DataSourceMode="List"
	SelectCommand="<Query><OrderBy><FieldRef Name='SortOrder' Ascending='true' /></OrderBy></Query>"
	<SelectParameters>
		<asp:Parameter Name="WebUrl" DefaultValue="/configuration/" />
		<asp:Parameter Name="ListName" DefaultValue="PersonTitles" />
	</SelectParameters>
</SPWebControls:SPDataSource>
 
<asp:DropDownList
	runat="server"
	ID="ddlPersonTitles"
	CssClass="title"
	DataSourceID="dsPersonTitles"
	DataTextField="Title"
	DataValueField="ID">
</asp:DropDownList>