Skip to content

Instantly share code, notes, and snippets.

@FH-Inway
FH-Inway / gist:939489e0b350d89cd770df8ee4431f81
Created October 16, 2021 11:08
d365fo.tools Enable-MaintenanceMode error
**********************
Windows PowerShell transcript start
Start time: 20211016130105
Username: AAA-1V-FH01\Administrator
RunAs User: AAA-1V-FH01\Administrator
Machine: AAA-1V-FH01 (Microsoft Windows NT 10.0.14393.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 7336
PSVersion: 5.1.14393.4530
PSEdition: Desktop
[ExtensionOf(classStr(FormRun))]
public final class FormRun_Class_Extension
{
/// <summary>
/// This allows unencrypted setting of the recordContext via the q querystring parameter:
/// q={"Parameters":[{"DataSource":"CustTable","FieldValues":[{"Field":"AccountNum","Value":"C123456789"}]}]}
/// </summary>
/// <param name = "_recordContext"></param>
/// <returns></returns>
public boolean applyRecordContext(str _recordContext)
@FH-Inway
FH-Inway / AutoDeployPatch.patch
Created March 13, 2022 11:00
Patch for AutoDeployReportAndSyncDB.ps1
--- AutoDeployReportAndSyncDB.ps1 Sun Mar 28 05:19:50 2021
+++ AutoDeployReportAndSyncDB_patched.ps1 Sun Apr 18 16:14:01 2021
@@ -22,6 +22,7 @@
[hashtable]$Credentials
)
#db sync
+invoke-Expression "net start reportserver"
$dbSyncScriptPath = "$PSScriptRoot\AutoDBSync.ps1"
$dbSyncScriptPath = Resolve-Path -Path $dbSyncScriptPath
@FH-Inway
FH-Inway / Get-D365FOComponents.ps1
Last active June 19, 2022 14:17
List D365FO T1 components
# Check PowerShell components
Get-Module -ListAvailable
# Check other components
git --version
# Check folders
Test-Path -Path "C:\Windows\System32\drivers\etc\hosts"
Test-Path -Path "C:\Windows\System32\inetsrv\Config\applicationHost.config"
Test-Path -Path "C:\FinancialReporting\Server\ApplicationService\bin\MRServiceHost.settings.config"
@FH-Inway
FH-Inway / gist:a1eba50d65331a484ff892dc25683291
Created June 19, 2022 11:37
Rename-D365ComputerName with invalid -NewName issue
PS C:\> Rename-D365ComputerName -NewName d365fo.tools -ShowOriginalProgress -Verbose
VERBOSE: [03:46:00][Rename-D365ComputerName] Testing for elevated runtime
VERBOSE: [03:46:00][Rename-D365ComputerName] Renaming computer to d365fo.tools
Rename-Computer : Skip computer 'MININT-57EHFHJ' with new name 'd365fo.tools' because the new name is not valid. The
new computer name entered is not properly formatted. Standard names may contain letters (a-z, A-Z), numbers (0-9), and
hyphens (-), but no spaces or periods (.). The name may not consist entirely of digits, and may not be longer than 63
characters.
At line:109 char:5
+ Rename-Computer -NewName $NewName -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@FH-Inway
FH-Inway / d365fo.tools-az.storage-test.log
Created June 26, 2022 13:46
Log of d365fo.tools Az.Storage test
PS C:\windows\system32> $repositoryModulePath = ".\d365fo.tools"
$azureStorageAccountId = "miscfiles"
$sas = "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk"
$container = "backupfiles"
$fileName = "Test.txt"
# Install d365fo.tools prerequisites
$modules = @("PSFramework", "PSScriptAnalyzer", "Az.Storage", "AzureAd", "PSNotification", "PSOAuthHelper", "ImportExcel")
foreach ($item in $modules) {
@FH-Inway
FH-Inway / d365fo.tools-az.storage-test.ps1
Created June 26, 2022 13:48
d365fo.tools Az.Storage test
# Replace the following three variables with values for your own azure storage
$azureStorageAccountId = "miscfiles"
$sas = "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk"
$container = "backupfiles"
$repositoryModulePath = ".\d365fo.tools"
$fileName = "Test.txt"
# Install d365fo.tools prerequisites
$modules = @("PSFramework", "PSScriptAnalyzer", "Az.Storage", "AzureAd", "PSNotification", "PSOAuthHelper", "ImportExcel")
# For debugging purposes, this script simulates how a call to [Get-D365LcsApiToken](https://github.com/d365collaborative/d365fo.tools/blob/development/d365fo.tools/functions/get-d365lcsapitoken.ps1)
# would execute the Invoke-RestMethod call.
# This script uses code from https://github.com/d365collaborative/PSOAuthHelper by @Splaxi
function Convert-HashToArgStringSwitch {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidDefaultValueSwitchParameter", "")]
[CmdletBinding()]
[OutputType([System.String])]
param (
[HashTable] $InputObject,
@FH-Inway
FH-Inway / Change page titles.user.js
Last active November 12, 2022 12:27
Tampermonkey script to change page titles
// ==UserScript==
// @name Change Microsoft Learn page titles
// @namespace https://github.com/FH-Inway/tampermonkey
// @version 0.3
// @description Changes titles of Microsoft Learn pages to provide better friendly links in Edge browser
// @author FH-Inway
// @match https://learn.microsoft.com/en-us/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=microsoft.com
// @updateURL https://gist.github.com/FH-Inway/471eabdc3d859b7ca9b83ff24289c0a1/raw/Change%2520page%2520titles.user.js
// @downloadURL https://gist.github.com/FH-Inway/471eabdc3d859b7ca9b83ff24289c0a1/raw/Change%2520page%2520titles.user.js
@FH-Inway
FH-Inway / Get-D365LCSSharedAssetFile.log
Created November 6, 2022 17:34
Get-D365LCSSharedAssetFile example
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\windows\system32> import-module -name "C:\Repositories\GitHub\FH-Inway\d365fo.tools\d365fo.tools"
PS C:\windows\system32> Get-D365LcsApiToken -ClientId e70cac82-6a7c-4f9e-a8b9-e707b961e986 -Username Lcs-Automation@contoso.com -Password fT1DHcLdeTWC9aumugHr -LcsApiUri https://lcsapi.lcs.dynamics.com | Set-D365LcsApiConfig -ProjectId 123456789
PS C:\windows\system32> $latestNugetFile = Get-D365LcsSharedAssetFile -FileType NuGetPackage -Verbose -Latest
VERBOSE: [09:24:00][Get-LcsSharedAssetFile] Invoke LCS request.
VERBOSE: GET https://lcsapi.lcs.dynamics.com/box/fileasset/GetSharedAssets?fileType=27 with 0-byte payload
VERBOSE: received 71295-byte response of content type application/json; charset=utf-8
VERBOSE: [09:24:02][Get-LcsSharedAssetFile] Total time spent inside the function was 00:00:01.4523220