Send instant message from server back to client using SignalR

UPDATED 28-08-2018: Added guidance to send message to specific client and not just for all + more screenshots on how _signalContextHub was added. This is a small blogpost explaining how to use SignalR for ASP Core 2.1 to send a message (or a signal :) ) from the server (controller action) back to the client view. Alot of posts explains how to make various bidirectional chats using SignalR to send messages from client to the server (from view to controller and back again), but the other way around (from server to client) is useful if you want to show progress bars [...]

By |2018-08-28T09:02:30+01:00august 9th, 2018|Scripting & Development|4 Comments

ASP.NET Core 2.0 MVC: editing complex viewmodels with child models and dynamically retrieve properties from the model in the view or just a REALLY long title…

For the past couple of months I've been doing ASP.NET Core coding projects – building the backend and frontend of various websites for our customers. This has been a fun experience, but at times also very frustrating when things aren’t really working out. One thing is to follow examples and tutorials based on “perfect world” scenarios, another is to deal with real-world data and requirements. So this will be my first post in hopefully a series of ASP.NET Core posts to share some tips and tricks when things get a little more complicated. I assume you have some knowledge of [...]

By |2018-08-09T12:52:22+01:00januar 31st, 2018|Scripting & Development|2 Comments

Using Office 365 Portal Security Token for Authentication with custom website

When creating a lot of different web front-ends, it is always rather complex to get started with single sign-on or integrated login. The simple way to not maintain a credential database or passwords is to validate against a 3. party website. This is where the Office 365 Portal comes in handy, especially because many companies are already validating against or with it. I created this code as part of another solution, the example here has been cut down for demonstration purposes and easy integration. You will be able to validate against Portal.microsoftonline.com as long as the login is allowed for [...]

By |2017-12-11T08:59:07+01:00december 11th, 2017|Office 365, Scripting & Development, Security|4 Comments

How to use SCCM SDK in C# with a WQL Query that contains joins

Sometimes you just stop and wonder: how DO you make a WQL query with joins and use it with the SCCM SDK in C#? It's that gnawing thought we all have right? So after spending an hour reading through people saying: "It's NOT supported!" and some people who said it was (without any examples whatsoever), I managed to get a small sample working. So if any of you should come across this challenge (which is of course the most of the world), then here is a code-example on how to do it: It's a small console application that output all [...]

Create and run scripts with the new feature “Run Powershell scripts from the ConfigMgr console” on current branch 1706

In my last post I talked about how we could activate the new feature "Run Powershell script from the ConfigMgr" on current branch 1706 and in this post I would like to talk about on how to get started using this wonderful feature once you have activated it. This feature really shows that the ConfigMgr product team over at Microsoft really listens to its community and that they do everything they can to improve the product. Tho this feature is a bit rough around the edges it shows great potential and i can't wait to see how it will evolve over time [...]

Remove non authorized members of the local administrator group with ConfigMgr

    MVP Jörgen Nilsson did a great post the other day over at https://4sysops.com/archives/monitoring-laps-with-configuration-manager/ where he showcased how one could monitor LAPS with the help of CI's in ConfigMgr to make sure it's installed and running properly. Continuing on the LAPS theme and ways ConfigMgr can help us improve security and maintain control I would like to talk a little about how we can remove non authorized members of the local administrator group with the help of Configuration Items/Baselines in ConfigMgr.   For those who are unfamiliar with LAPS (Local administrator password solution) you can learn more here: https://technet.microsoft.com/en-us/mt227395.aspx     [...]

Watch out when using $PSModuleAutoLoadingPreference = “none” in a PS Remote Session in Windows Server 2016

Recently I discovered a change in the default behavior of PSRemoting Sessions in Windows Server 2012 R2 vs. Server 2016. I was migrating a script from 2012R2 to 2016 and surprisingly, I got this error:   The term 'Get-Date' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included , verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Get-Date:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : ctaa01   When I vestigated the issue I found that [...]

ConfigMgr 1604 new cmdlets

Microsoft released a new set of command-lets for Configuration Manager and all these new cmdlets are also included in the ConfigMgr 1605 TP release. Here are all the new cmdlets: cmdlet Category Notes Get-CMWindowsServicingPlan Software Updates Windows 10 Servicing New-CMWindowsServicingPlan Software Updates Windows 10 Servicing Add-CMServiceConnectionPoint Infrastructure Set-CMServiceConnectionPoint Infrastructure Remove-CMServiceConnectionPoint Infrastructure Get-CMServiceConnectionPoint Infrastructure Remove-CMCertificateRegistrationPoint Infrastructure Set-CMCertificateRegistrationPoint Infrastructure Add-CMCertificateRegistrationPoint Infrastructure Get-CMCertificateRegistrationPoint Infrastructure Invoke-CMDeviceAction Resource Management Get-CMDeviceActionState Resource Management Add-CMIntuneSubscription MDM / Hybrid Set-CMIntuneSubscription MDM / Hybrid Get-CMIntuneSubscription MDM / Hybrid Remove-CMIntuneSubscription MDM / Hybrid Add-CMMdmEnrollmentManager MDM / Hybrid Remove-CMMdmEnrollmentManager MDM / Hybrid Get-CMMdmEnrollmentManager MDM / Hybrid New-CMApnsCertificateRequest MDM / Hybrid New-CMDepTokenRequest [...]

FTP / SFTP monitor for SCOM

In this post we'll make a script for a FTP / SFTP monitor that can monitor the FTP/SFTP status, by doing the following operations: -Log in -Upload a file -Download a file -Delete the file Since Powershell doesn't have any built-in ftp support I was looking for some alternatives, and since I use WinSCP normally for ftp/sftp I found that they also support Powershell scripting, so why not take advantage of this? This guide was written with great help from WinSCP's own page: https://winscp.net/eng/docs/library_powershell Get the SSH fingerprint (This part is only nessary for the SFTP solution). Since we need the SSH [...]

Silent install Java 8 Update 71 and 72 with SCCM

In my last post about silent / unattended installation of Java 8 Update 66, we followed the new guidelines for how to install Java 8 silently by Oracle. The problem with that method is that it works when you try to run your script locally with administrator privileges it will work fine, but when you run the same script through SCCM / Configuration Manager, it will fail. And just to confuse you even more, it will only fail for the 32-bit version of java, not the 64-bit, even though you use the exact same method. This problem have been reported [...]

Roll Out New Configuration Manager Distribution Point with PowerShell

Here is a quick example how to install new Configuration Manager Distribution Point with PowerShell. As you see we have many options to expand this script. We can install Windows Server features, reboot it remotely, install additional software etc. It all depends how you wanna install and configure it. #Import the Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE #Change the connection context Set-Location "$($SiteCode.Name):\" #New DP Information $DistributionPoint = 'DP01.4demo4.com' $SiteCode = 'PS1' # Test the connection to server     Test-Connection `         -ComputerName $DistributionPoint # OPTIONAL - Install Windows Server Roles and Features     Install-WindowsFeature `         -Name [...]

December 2nd: Part 2: Uninstall Java (or any other software) with ConfigMgr Compliance Baselines

It's December 2nd and Christmas is just around the corner! Yesterday Jakob kicked off the Coretech December Calendar with a great post about "Triggering a webhook from a SharePoint workflow using Out-of-the-box Activities" (Check out his blog post here: http://bit.ly/1N16fte).  That was the  first, this is the second post in the Coretech blog series that will continue until December 24th - Christmas Eve! :) In Part 1 (http://bit.ly/1PlnDPr) I explained how you can utilize ConfigMgr Compliance Baselines for uninstalling software like Java, Adobe etc. with the help of PowerShell and WMI. Well in Part 1 we used the Win32_Product class which is not recommended [...]

Troubleshooter note: SQL Installation fails with exitcode 0x84BB0001 on a ReFS formatted partition.

So I tried to install SQL the other day for a new ConfigMgr environment, but I kept getting an error during the first seconds of the installation with 0x84BB0001 as the exit code. With some quick investigation into the log files I found this%Temp%\SqlSetup_Local.log:C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\Summary.txt: Shows that the installation has difficulties installing on a ReFS formatted partitionDisk Manager Shows that D:\ is formatted with ReFS (I blame my PowerShell Script :)): Now the quick and easy way of fixing this is to reformat the partition to NTFS. And this is what I did in this case. But [...]

By |2015-10-11T19:05:00+01:00oktober 11th, 2015|Configuration Manager (SCCM), Scripting & Development, SQL|Kommentarer lukket til Troubleshooter note: SQL Installation fails with exitcode 0x84BB0001 on a ReFS formatted partition.

Upgrade System Center Configuration Manager Console with PowerShell

Since Service Pack 1 was released to SCCM 2012 R2 I have been upgraded several environments. A couple of customers wanted me to create a PowerShell script to uninstall existing ConfigMgr Console and install the new updated version with the latest cumulative updates and hotfixes. If you create a package to distribute it with SCCM make sure you point the Data source to the location of the Client installations files, Script, KB3084586-msp and kb3074857-msp. Installation command for the program will then be: PowerShell.exe -file "script.ps1". Remember to set PowerShell execution policy to "Bypass" under Client Settings. This will not affect [...]

By |2015-09-17T18:14:33+01:00september 17th, 2015|Configuration Manager (SCCM), General info, Powershell, Scripting & Development|Kommentarer lukket til Upgrade System Center Configuration Manager Console with PowerShell

Azure Automation: New Features announced!

Today at the PowerShell summit in Stockholm,  Joe Levy and Anatoli Beliaev of Microsoft announced a bunch of new features that is publicly available in Azure Automation! Unfortunately I was not able to be there in person, but luckily multiple people tweeted about this stuff! (Thanks @vNiklas + @skillriver + more!! ) Some of the features is what I have demoed at multiple session within the last month. (SCU + User groups). Here is the list: Gallery Support Gallery has been expanded and has a nice button for it the gallery now also includes powershell scripts. PowerShell Script Runbooks Use [...]

By |2015-09-15T14:03:34+01:00september 15th, 2015|Azure, Scripting & Development|Kommentarer lukket til Azure Automation: New Features announced!

Automate Signature And Status Reports With PowerShell – Windows Defender (.txt file)

What you will be able to after reading this blog: Get the latest information about "your" Signature- & Anti Virus reports in Windows Defender and make it into a text file. How to automate it, so it will run every day and give you a status report with time and date. Being able to look at what time and date the latest updates have been completed. First of all, we have to create a folder/directory where the status reports can be stored in. Open up PowerShell in administrative mode and run this script only by copy-paste: $path="C:\" New-Item .\AVStatusReports -ItemType [...]

PowerShell Script That Creates A Folder And A Shortcut On Your Desktop

Basic example of a script that creates a folder in your Local Disk "C"  and then makes a shortcut on desktop so you have easy access to the folder. First of all, open your powershell as administrator and make sure you are at a place where you are able to create folders such as the C:\ drive. PS C:\WINDOWS\system32> cd .. PS C:\WINDOWS> cd .. PS C:\> And now you are able to run the script! - Copy and paste what is written below $path = "C:\" New-Item .\EpicFolder -ItemType Directory -Force $wshshell = New-Object -ComObject WScript.Shell $desktop = [System.Environment]::GetFolderPath('Desktop') [...]

By |2015-09-14T14:21:32+01:00september 14th, 2015|General info, Powershell, Scripting & Development|Kommentarer lukket til PowerShell Script That Creates A Folder And A Shortcut On Your Desktop

Azure Automation DSC: How to register and use Azure Automation DSC

One of the new features of Azure Automation is still somewhat hidden. It needs to be enabled before you see it in the GUI This blog post gives a quick overview of what is needed to use it.   Step 1: Enable the extension in your Azure Account #Add & Select Account Add-AzureAccount Switch-AzureMode -Name AzureResourceManager #Register DSC extension on account Register-AzureProvider –ProviderNamespace Microsoft.Automation Register-AzureProviderFeature -FeatureName dsc -ProviderNamespace Microsoft.Automation The command registers the azure automation dsv extension on your account. This shows the DSC Nodes tile in your automation account:     Step 2: Select subscription and default values Before [...]

PowerShell: LEAP Motion PowerShell Lottery Script @ Danish PowerShell User Group

In our geek club aka The Danish PowerShell user group, we always do a lottery in the end, for books or similar. To draw the correct winner we have been using a script that I have developed. I have for a long time, promised to release the script so that other user groups or other interested people can use it for fun! It has amazing ascii graphics and colors!!! It will take you straight back to your C64 loading screen! The script is a lottery script that takes a file from www.eventbrite.com containing all attendees. The script need a LEAP [...]

By |2015-06-22T14:59:47+01:00juni 22nd, 2015|Powershell, Scripting & Development|Kommentarer lukket til PowerShell: LEAP Motion PowerShell Lottery Script @ Danish PowerShell User Group

Create Status Filter Rules with PowerShell

Here is a quick example of creating a Status Filter Rule in Configuration Manager with PowerShell #Example 1 New-CMStatusFilterRule -SiteCode PS1 -Name 'Remove PC from OSD Collection' -MessageId 11144 -MessageType Milestone ` -RunProgram $True -ProgramPath 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Scripts\Remove-CMDeviceFromCollection.ps1 -CollectionName "OSD Windows 8 Standard" -ComputerName %msgsys' #Example 2 $Parameters = @{ SiteCode = 'PS1' Name = 'Remove PC from OSD Collection' MessageId = 11144 MessageType = 'Milestone' RunProgram = $True ProgramPath = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Scripts\Remove-CMDeviceFromCollection.ps1 -CollectionName "OSD Windows 8 Standard" -ComputerName %msgsys' } New-CMStatusFilterRule @Parameters Execute the code     Happy Scripting

By |2015-03-23T13:16:47+01:00marts 23rd, 2015|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Create Status Filter Rules with PowerShell

Beyond unsupported – How to add PowerShell ISE to ConfigMgr Admin Console

As you already know, then currently we can only start PowerShell Console through Configuration Manager Admin Console but most likely  you may want to start PowerShell ISE through Admin Console :) Step-by-step guide First, this is not supported so don’t blame me if something is not working. Please also remember that there is no SAVE button in Admin Console Builder Tool! Close ConfigMgr Admin Console Start AdminUI.ConsoleBuilder.exe – You can find this tool under the Admin Console installation folder   Select File –> Open –> ConnectedConsole Select View->Application Menu Items Select Connect via Windows PowerShell and right-click select Clone Now [...]

Working with Queries in ConfigMgr with PowerShell

I accidentally blew up my dev lab and now I need to build a new one but luckily we have PowerShell :). In this picture we have 8 Queries and I would like to create Device Collections based on these Queries. These Queries are built with Servicing Extension.   Here are some of the commands that we can use in Configuration Manager 2012 R2 CU4. These commands allows us easily export/import Queries from one system to another and much more. #Import Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Get all CM Queries $Queries = Get-CMQuery #Total Queries [...]

Quick intro to Configuration Items in ConfigMgr with PowerShell

Configuration Items that I would like to export and import   Here are some command examples that we can use in Configuration Manager 2012 R2 CU4. #Import Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Get all CIs $ConfigurationItems = Get-CMConfigurationItem #Total CIs $ConfigurationItems.Count #Get CIs only with specific keyword $ConfigurationItems = Get-CMConfigurationItem -Name "*CT - *" -ForceWildcardHandling #CI rules with 'CT - ' keyword - 12 CIs in this example $ConfigurationItems.Count #Export out CIs with 'CT - ' keyword foreach($CI in $ConfigurationItems){ Write-Output -InputObject "Exporting out $($CI.LocalizedDisplayName) CI" Export-CMConfigurationItem -Path "$env:USERPROFILE\Desktop\CI_Rules\$($CI.LocalizedDisplayName).cab" -InputObject $CI } #New CI folder [...]

By |2015-03-16T09:50:54+01:00marts 16th, 2015|Configuration Manager (SCCM), Powershell, Scripting & Development|Kommentarer lukket til Quick intro to Configuration Items in ConfigMgr with PowerShell