Skip to content

Instantly share code, notes, and snippets.

@andyhuey
andyhuey / get-auth-hdr-1.ps1
Created April 7, 2023 12:47
Get the auth hdr and send it to the clipboard.
# get-auth-hdr-1.ps1
# Get the auth hdr and send it to the clipboard.
# ajh 2023-04-06: new.
#Requires -Version 7
#Requires -Modules @{ ModuleName="MSAL.PS"; ModuleVersion="4.0" }
# force TLS 1.2
$TLS12Protocol = [System.Net.SecurityProtocolType] 'Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $TLS12Protocol
@andyhuey
andyhuey / get-auth-hdr-0.ps1
Last active April 7, 2023 13:20
Get the auth hdr and send it to the clipboard. (old)
# get-auth-hdr-0.ps1
# Get the auth hdr and send it to the clipboard.
# ajh 2022-08-29: rewrite to use MSAL.PS.
# ajh 2022-11-23: read secret from env vars.
#Requires -Version 5.1
#Requires -Modules @{ ModuleName="MSAL.PS"; ModuleVersion="4.0" }
# force TLS 1.2
$TLS12Protocol = [System.Net.SecurityProtocolType] 'Tls12'
@andyhuey
andyhuey / tag-cloud-ex.html
Created August 20, 2020 18:51
Blogger tag cloud code from 2010
<!-- originally taken from http://phydeaux3.blogspot.com/2007/05/automatic-list-of-labels-for-classic.html -->
<div id="labelList" class="BlogBody"></div> <script type="text/javascript">
//<![CDATA[
function listLabels(root){
var baseURL = '/search/label/';
var baseHeading = "My Tags";
var isFTP = false;
var llDiv = document.getElementById('labelList');
var entry = root.entry;
var h1 = document.createElement('h1');
@andyhuey
andyhuey / wcf-example.cs
Created September 23, 2019 23:15
Calling a Dynamics AX WCF service from .NET Core
// old way:
public async Task RunAsync()
{
CallContext context = new CallContext();
context.Company = "axcompany";
string pingResp = string.Empty;
var client = new XYZPurchInfoServiceClient();
var rv = await client.wsPingAsync(context);
pingResp = rv.response;
Console.WriteLine("Ping response: {0}", pingResp);
@andyhuey
andyhuey / enable_tls12.ps1
Created February 10, 2017 18:15
Enable TLS 1.2
# Enables TLS 1.2 on Windows Server 2008 R2 and Windows 7
# adapted from https://www.derekseaman.com/2010/06/enable-tls-12-aes-256-and-sha-256-in.html
# Must run as admin. Reboot after running.
$tls12key = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2"
if (Test-Path $tls12key) {
Write-Host "TLS 1.2 key already exists."
exit
}
@andyhuey
andyhuey / deleteAllFromList.cs
Created December 21, 2016 20:39
CSOM code to delete all items from a SharePoint list
private void deleteAllFromList(ClientContext cc, List myList)
{
int queryLimit = 4000;
int batchLimit = 100;
bool moreItems = true;
string viewXml = string.Format(@"
<View>
<Query><Where></Where></Query>
<ViewFields>
@andyhuey
andyhuey / doesVendorRecExist.cs
Created December 17, 2016 00:29
a bit of SharePoint CSOM code
private bool doesVendorRecExist(string companyCode, string vendorNum,
List vendorList, ClientContext cc)
{
CamlQuery spq = new CamlQuery();
spq.ViewXml = string.Format(@"
<View><Query>
<Where><And>
<Eq><FieldRef Name='VendorNo' /><Value Type='Text'>{0}</Value></Eq>
<Eq><FieldRef Name='CompanyName' /><Value Type='Text'>{1}</Value></Eq>
</And></Where>
@andyhuey
andyhuey / tfpt_ex1.ps1
Last active August 29, 2015 14:16
TFPT query exmple
# Given AX project #, return ID.
param (
[string]$projno = $( Read-Host "Enter project # (e.g. 123.4)" )
)
[string]$tfpt = "C:\Program Files (x86)\Microsoft Team Foundation Server 2012 Power Tools\TFPT.EXE"
[string]$svr = "http://myTfsServer:8080/tfs/defaultcollection"
[string]$projname = "myProjName"
[string]$query = "SELECT [System.Id], [System.Title] FROM WorkItems " +
"WHERE [System.TeamProject] = '$projname' " +
@andyhuey
andyhuey / AjhTestRSL
Created October 10, 2014 23:11
RecordSortedList test
static void AjhTestRSL(Args _args)
{
CustTable custTable;
RecordSortedList myList = new RecordSortedList(tableNum(CustTable));
boolean moreRecs;
myList.sortOrder(fieldNum(CustTable, AccountNum));
// create a list
while select firstOnly10 * from custTable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace MySuit.MySuitV2.BLL
{
public class Utility
{