Skip to content

Instantly share code, notes, and snippets.

@FH-Inway
FH-Inway / CallSearchScriptForPowerShellModuleCommands.ps1
Last active July 15, 2023 13:01
Search multiple terms in folder
$folderPath = "C:\Repositories\Github\FH-Inway\d365fo.tools"
$moduleName = "AzureAD"
. .\SearchFilesForTerms.ps1
# Import the module with the commands to search for
Import-Module $moduleName
# Get all commands from the module, including aliases
$moduleCommands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name
@FH-Inway
FH-Inway / d365fo-odata-balancecontrol.xml
Created July 13, 2023 14:24
D365FO EDMX trimmed to BalanceControl
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="Microsoft.Dynamics.DataEntities" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityType Name="BalanceControl">
<Key>
<PropertyRef Name="dataAreaId" />
<PropertyRef Name="MainAccountId" />
<PropertyRef Name="ChartOfAccounts" />
</Key>
@FH-Inway
FH-Inway / devcontainer.json
Created July 8, 2023 12:11
Codespaces with PowerShell
{
"image": "mcr.microsoft.com/powershell:latest",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/natescherer/devcontainers-custom-features/powershell-resources": {
"resources": "PSFramework,PoshRSJob"
}
},
"customizations": {
"vscode": {
@FH-Inway
FH-Inway / Download-D365FOODataSpecification.ps1
Created July 3, 2023 11:40
Download D365FO OData specification
$MetaDataUrl = 'https://<YourSiteURL>/data/$metadata'
$Outfile = 'C:\Temp\d365fo-odata.edmx'
If (!$Cred){ $Cred = Get-Credential}
Write-Output "Downloading OData specification..."
Invoke-WebRequest -Credential $Cred -Uri $MetaDataUrl -OutFile $Outfile
@FH-Inway
FH-Inway / Format-CommentBasedHelp.ps1
Last active June 25, 2023 14:51
d365fo.tools setup + .vscode folder
# Script to format the comments/documentation of the cmdlets used for the commend based help.
# based on https://gist.github.com/Splaxi/ff7485a24f6ed9937f3e8da76b5d4840
# See also https://github.com/d365collaborative/d365fo.tools/wiki/Building-tools
$moduleName = "d365fo.tools"
#$path = "C:\GIT\GITHUB\$moduleName.Workspace\$moduleName\$moduleName"
$path = "C:\Repositories\d365fo.tools\$moduleName"
function Get-Header ($text) {
$start = $text.IndexOf('<#')
$temp = $start - 2
@FH-Inway
FH-Inway / Change Yammer page titles.user.js
Last active November 28, 2022 18:06
Tampermonkey script to change Yammer page titles
// ==UserScript==
// @name Change Microsoft Yammer Feedback program page title
// @namespace https://github.com/FH-Inway/tampermonkey
// @version 0.3
// @description Changes titles of Microsoft Yammer Feedback program pages to provide better friendly links in Edge browser
// @author FH-Inway
// @match https://www.yammer.com/dynamicsaxfeedbackprograms/
// @icon https://www.google.com/s2/favicons?sz=64&domain=yammer.com
// @updateURL https://gist.github.com/FH-Inway/74e6cd22c98b8b359fdc715a9f621fea/raw/Change%2520Yammer%2520page%2520titles.user.js
// @downloadURL https://gist.github.com/FH-Inway/74e6cd22c98b8b359fdc715a9f621fea/raw/Change%2520Yammer%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 [email protected] -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
@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
# 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 / 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")