Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Friday, 15 September 2017

Inline Images not showing for Work Items in Visual Studio with 401 unauthorized error

To fix this, right click the broken image link from the Visual studio work item description pane, then copy the link from the properties dialog (it looks like a label, but you can select all on it by right mouse clicking).

image

Then simply copy and paste that into Internet Explorer bar, and when prompted enter your credentials.

Next, back in Visual Studio, just click the refresh work item button on the header of the work item window, and do this once for each in line image in the description.

Friday, 2 June 2017

Visual Studio Work Item Images broken

The case of the missing image…

image

Turns out this was due to my old windows credentials being cached on the tfs server credentials cache.

To fix this, I logged onto the tfs server directly via my admin account and updated the credentials there in the windows credentials manager.

Also ran fiddler in the background and cleared the winnet cache as well

Then it refresh a few times on the work item ticket back in visual studio, and hey presto they are all showing again.

Friday, 4 November 2016

Powershell for finding hotfixes

One liner:

$Session = New-Object -ComObject Microsoft.Update.Session; $Searcher = $Session.CreateUpdateSearcher(); $HistoryCount = $Searcher.GetTotalHistoryCount();$Searcher.QueryHistory(0,$HistoryCount) | Sort-Object -Property Date -Descending | Select Title, Date | Export-Csv -Path c:\temp\hotfixlist.csv

More full version:


$wu = new-object -com “Microsoft.Update.Searcher”

$totalupdates = $wu.GetTotalHistoryCount()

$all = $wu.QueryHistory(0,$totalupdates)

# Define a new array to gather output
$OutputCollection=  @()
             
Foreach ($update in $all)
    {
    $string = $update.title

    $Regex = “KB\d*”
    $KB = $string | Select-String -Pattern $regex | Select-Object { $_.Matches }

     $output = New-Object -TypeName PSobject
     $output | add-member NoteProperty “HotFixID” -value $KB.‘ $_.Matches ‘.Value
     $output | add-member NoteProperty “Title” -value $string
     $OutputCollection += $output

    }

# Oupput the collection sorted and formatted:
$OutputCollection | Sort-Object HotFixID | Format-Table -AutoSize | Out-File c:\temp\output.txt

Further reading
https://github.com/tomarbuthnot/Get-MicrosoftUpdate

Thursday, 30 June 2016

Macro for connecting Visual Studio to windows service for debugging

Got this through today from my old colleague Kevin McConaghy,…
 
1.  Hack for service OnStart event, essentially to stall the service for long enough for the VS Extension to connect after starting it, only in debug mode and only if you send a special argument.
 
        protected override void OnStart(string[] args)
        {
#if DEBUG
            // If the "WaitForDebugger" argument is passed, wait for 15 seconds for a debugger to become attached.
            if (args.OfType<string>().Contains("WaitForDebugger"))
            {
                for (var i = 1; i <= 15; i++)
                {
                    if (Debugger.IsAttached)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                // If no debugger is attached, abort attempt to start service.
                if (!Debugger.IsAttached)
                {
                    Stop();
                    return;
                }
            }
#endif
2. The vCmd script, this automates the starting of the service if it is not started, and then the connection of the debugger to the process.
using EnvDTE;
using EnvDTE80;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.ServiceProcess;
public class C : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
    {
        var serviceName = "MessagingService";
        using(var serviceController = new ServiceController(serviceName))
        using(var serviceManagement = new ManagementObject("Win32_Service.Name='"+serviceName+"'"))
        {
            // Start service with "WaitForDebugger" parameter, if the service is stopped.
            if (serviceController.Status == ServiceControllerStatus.Stopped)
            {
                serviceController.Start(new []{"WaitForDebugger"});
            }
            // Attach debugger to process.
            var servicePath = serviceManagement.Properties["PathName"].Value.ToString().Trim('\"');
            try
            {
                var serviceProcess = DTE.Debugger.LocalProcesses.OfType<Process>().Single(x => x.Name == servicePath);
                serviceProcess.Attach();
                return;
            }
            catch(Exception ex)
            {
                System.Windows.MessageBox.Show(string.Format("Could not find process: {0}, {1}.", servicePath, ex.Message));
            }
        }
    }
}
3. The script requires the following references, added via the button.
System.Core
System.Linq
System.ServiceProcess
System.Management





Thursday, 23 June 2016

Setting up the task board in TFS

First ensure that you have set up the backlog iteration, to be one above the iteration path for your sprint items, and then check the items for your sprint iteration here

http://tfs.com:8080/tfs/DefaultCollection/TeamProjectName/_admin/_iterations

Then use this link to get to the task board

http://tfs.com:8080/tfs/DefaultCollection/TeamProjectName/_backlogs/TaskBoard/#_a=requirements

Monday, 9 May 2016

Unshelving from one branch to another in TFS

 

This works fine…

tfpt unshelve /migrate /source:$/MyProject/Fb3.9.8 /target:$/MyProject/Main

But put quotes round and it does NOT work

tfpt unshelve /migrate /source:"$/MyProject/Fb3.9.8" /target:"$/MyProject/Main"

Further information can be found here…

http://geekswithblogs.net/TarunArora/archive/2011/06/06/unshelve-shelveset-created-from-one-branch-to-another.aspx

Tuesday, 26 April 2016

JetBrains dotMemory not attaching = reload .NET perf counters

If you get an issue using dotMemory where it wont connect to the profiler, then run the following two commands from a .net command prompt…
unlodctr .NETFramework
lodctr C:\Windows\Inf\.NETFramework\corperfmonsymbols.ini

Friday, 22 January 2016

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 "Description -like 'London'"  -Properties Name, Title, Manager, whenCreated, DistinguishedName, LastLogonDate | ? whenCreated  -gt $lastWeek | select Name, Title, Manager, 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’

Monday, 20 July 2015

The case of the disappearing TFS task board

So after wondering where all our tasks had disappeared to, it turns out that someone had changed the default Area path, and ticked it in the _admin/_areas section of the portal.

This has the knock on affect of removing any items from the task board that are not under ticked area paths, hence the stuff that was in our task board disappeared, even though the items were all still there in TFS and accessible via team explorer.

Wednesday, 15 July 2015

Work Item finding with advanced search criteria in Visual Studio 2013

Hi guys

Something that's proving very useful to me now is the fact that you can use advanced search functionality in the quick search box in Visual Studio 2013 to find tickets that you're after.

Example 1,

1. Hit Ctrl+# to enter the team explorer search box

2. Drop down the arrow, and click the assigned to
image

3. Hit enter

This will then find all the work items assigned to you by default, although you can change the name to someone else to see what they're working on e.g.

image

Example 2 ,

1. Hit Ctrl+# to enter the team explorer search box

2. Type "Stack Rank":3.75

3. Hit Enter

You'll then get back all items where the stack rank is equal to 3.75

clip_image006

Other search examples as follows:

For all work items that have been changed on a given date

"Changed Date":2015-07-14

For all work items authorized by someone

"Authorized As":"Name Here"

For all bugs changed today

T:"Bug" "Changed Date":2015-01-14

For all items that you uploaded to TFS today

"Authorized As":"@Me" "Changed Date":2015-07-14

That last one is particularly useful, if you've just forgotten the task number you checked in and closed

image

Wednesday, 8 July 2015

SQL Management Studio short cuts

Hi guys

Not sure how many of you already knew this, but stumbled across a couple of SQL management studio shortcuts today that I was previously unaware of, and hit quite by accident.

Subsequently discovered that you can pre-configure your own as well, in  Tools, Options,  Keyboard….

clip_image002

More here

https://msdn.microsoft.com/en-us/library/ms174205.aspx

Thursday, 14 May 2015

C# 6 and Roslyn plugins to VS 2015 RC

In order to get the refactoring support listed here...

https://github.com/DustinCampbell/CSharpEssentials

you can simply install the following versions of the Tools, Extensions and Updates in Visual Studio 2015 RC.

image

Wednesday, 22 April 2015

Catastrophic failure when attaching Visual Studio Debugger to IISExpress

Symptom: Unable to attach to the process. Catastrophic failure.
Resolution: Change project settings to enable edit and continue, then press F5 to start the web project in debug mode.
image
I also deleted my solution.suo file from the solutions directory as it was over 3MB! - more about that here -http://merrickchaffer.blogspot.co.uk/2012/02/visual-studio-hanging-running-slowly.html


Monday, 23 February 2015

Windows 7 Weather Gadget: Cannot connect to service issue

Please follow this to fix the issue.

  1. Go to %localappdata%\Microsoft\Windows Live\Services\Cache
  2. Open "Config.xml" , Right click on it Select Edit, it will open in Notepad.
  3. Click on File>> Save (without doing any changes)
  4. Restart the Gadget after a Minute and it should start working.

However, it may be a temporary fix.  Many (myself included) report the problem returning. 

(Note: This fix appears to work, even if you're testing in IE10 with ActiveX settings as follows, using this code here http://jsfiddle.net/4aww6o3t/

and you get the Access is denied error from the call to oMSN.GetService("weather")

image

try
{
    // Connect to Weather Service .dll
    var oMSN = new ActiveXObject("wlsrvc.WLServices");
    var oMSN2 = new ActiveXObject("wlsrvc.WLServices");
    this.oMSN = oMSN.GetService("weather"); // Object to send and recieve weather data queries and to poll for service existence
    this.oMSN2 = oMSN2.GetService("weather"); // Object to send a latlong query and recieve a location code corresponding to the latlong
}
catch (objException)
{
    this.isValid = false;
    this.statusMessage = getLocalizedString('ServiceNotAvailable');
    this.oMSN = new Object();
    this.oMSN2 = new Object();
}

Update: 10:48 03/03/2015

Have just managed to write a batch file that fixes this issue ongoing. By adding this batch file to a scheduled task using the Task Scheduler, I've managed to get the gadget to always work now.

Note to use this batch file you'll just have to create a copy of the Settings.ini and call it Settings3Monitors.ini in the folder %userprofile%\AppData\Local\Microsoft\Windows Sidebar

taskkill /IM sidebar.exe /T /F

REM Fix for windows security update

pushd "%localappdata%\microsoft\windows live\services\cache"

IF EXIST ConfigOriginal.xml. (

     echo ConfigOriginal.xml file exists

) ELSE (

     copy Config.xml ConfigOriginal.xml

)

attrib "%localappdata%\microsoft\windows live\services\cache\*.xml" -r

del Config.xml

copy ConfigOriginal.xml Config.xml

echo. >> "Config.xml"

popd

REM Restart sidebar

pushd "%userprofile%\AppData\Local\Microsoft\Windows Sidebar"

xcopy /Y Settings3Monitors.ini Settings.ini

popd

start "" sidebar.exe

Monday, 16 February 2015

TFS Http 404 not found error

If you get an HTTP 404 not found error when connecting to TFS

clip_image002

Delete all the files in this folder

%userprofile%\AppData\Local\Microsoft\Team Foundation\4.0\Cache

You also may receive an error message in the VS 2013 output window, reading as follows...

We were unable to automatically populate your Visual Studio Online accounts.

The following error was encountered: One or more errors occurred.TF205020: Could not connect to server ‘tfs.russellreynolds.com\DefaultCollection’. This server was used in your last session, but it might be offline or unreachable. Confirm that the server is available on the network. To attempt to connect again, or to a different server, click ‘Connect To Team Foundation Server’ in Team Explorer or the Team menu.

The server returned the following error: HTTP code 404: Not Found

Monday, 2 February 2015

MVC / Jquery unobtrusive validation

http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-1

Also for how do attach a new client side method to unobtrusive validation e.g.

jQuery.validator.unobtrusive.adapters.add(adapterName, [params], fn);

see this article...

http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html

 

Note: For any element a in your <form>, you can do this to figure out what validation is attached to the containing <form> for that element...


$.data(a.form, "validator").settings.rules

e.g.

$.data(a.form, "validator").settings.rules.MiddleInitial
Object {maxlength: "1", __dummy__: true}

$.data(a.form, "validator").settings.messages.MiddleInitial
Object {maxlength: "The middle initial must be a single charater"}

Monday, 8 December 2014

Data dash attributes in ASP.NET MVC

http://stackoverflow.com/questions/4844001/html5-data-with-asp-net-mvc-textboxfor-html-attributes

You could use underscore (_) and the helper is intelligent enough to do the rest:

Html.TextBoxFor(
model => model.Country.CountryName,
new { data_url = Url.Action("CountryContains", "Geo") }
)

And for those who want to achieve the same in pre ASP.NET MVC 3 versions they could:

<%= Html.TextBoxFor(
model => model.Country.CountryName,
new Dictionary<string, object> {
{ "data-url", Url.Action("CountryContains", "Geo") }
}
) %>

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...