This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function New-TemporaryDirectory { | |
| [CmdletBinding()] | |
| Param () | |
| Process { | |
| [string]$path = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath ([System.Guid]::NewGuid()) | |
| New-Item -ItemType Directory -Path $path | |
| } | |
| } | |
| function Update-BacPacChecksum { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Get-aduser myUsername -Properties lastlogondate, lastlogon, lastlogontimestamp | select lastlogondate, lastlogon, lastlogontimestamp | |
| #LastLogonDate is a DateTime | |
| #LastLogon is a Long / Int64 | |
| #LastLogonTimestamp is a Long / Int64 | |
| #NB: values may differ slightly, as LastLogonDate/LastLogonTimestamp is cached for up to 2 weeks before replicating to all servers, whilst LastLogon is updated instantly but only on the users logon server: https://serverfault.com/a/734641/137255 | |
| $lastLogonTimeLdap = 131723288263417819 | |
| #The official way | |
| [DateTime]::FromFileTimeUtc($lastLogonTimeLdap) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --before running the below code, ensure you've set up a linked server per notes here: https://blog.sqlauthority.com/2016/03/30/sql-server-query-active-directory-data-using-adsi-ldap-linked-server/ | |
| declare @pageSize bigint = 900 | |
| , @usnMax bigint = 0 | |
| , @usnMaxPrevious bigint = -1 | |
| , @ldapPath nvarchar(max) = 'LDAP://myDomain.myForest.myCompany.com/DC=myDomain,DC=myForest,DC=myCompany,DC=com' | |
| , @columnList nvarchar(max) | |
| , @dynamicSql nvarchar(max) | |
| , @dynamicSqlTemplate nvarchar(max) = ' | |
| INSERT INTO #PagedAdsi (@columnList) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Compare-ObjectProperties { | |
| [CmdletBinding()] | |
| Param( | |
| [Parameter(Mandatory = $true)] | |
| $InputObject | |
| , | |
| [Parameter(Mandatory = $true)] | |
| $CompareObject | |
| ) | |
| Process { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-LdapAttributeInfo { | |
| [CmdletBinding()] | |
| Param () | |
| Process { | |
| $pages = [xml](Invoke-RestMethod -Method Get -Uri 'https://msdn.microsoft.com/en-us/library/ms675090(v=vs.85).aspx' -UseBasicParsing -UseDefaultCredentials) #lists all AD attributes | |
| [System.Xml.XmlNamespaceManager] $nsMgr = New-Object -TypeName System.Xml.XmlNamespaceManager($pages.NameTable) | |
| $nsMgr.AddNamespace('ns','http://www.w3.org/1999/xhtml') | |
| $pages.SelectNodes("/ns:html/ns:body/ns:div[@id = 'page']/ns:div[@id = 'body']/ns:div[@id = 'content']/ns:div[@class = 'topic']/ns:div[@id = 'mainSection']/ns:dl/ns:dd/ns:a/@href",$nsMgr) | select -ExpandProperty Value | %{ | |
| $result = [pscustomobject]@{ | |
| Documentation = $_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-VstsCost { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
| [ValidateRange(0,1000)] | |
| [Int]$NoOfUsers | |
| ) | |
| Begin { | |
| # data from: https://www.visualstudio.com/team-services/pricing/ | |
| $Tiers = @{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ConvertTo-QueryString { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
| [Hashtable]$Parameters | |
| ) | |
| Process { | |
| ($Parameters.Keys | %{"$_=$($Parameters[$_])"}) -join '&' | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Clear-Host | |
| function Extract-XPaths { | |
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
| [System.Xml.XmlElement]$elem | |
| ) | |
| Process { | |
| [string]$name = $elem.LocalName | |
| $name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Question: https://stackoverflow.com/q/50278559/361842 | |
| //Fiddle: https://dotnetfiddle.net/26rxWs | |
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| //consider using classes with public static members instead of enums if you want to add any functionality over Suits or Titles: https://stackoverflow.com/a/12675874/361842 | |
| public enum Suit | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ::Package Installation Instructions per: https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/migration-upgrade/install-metadata-hotfix-package | |
| ::Source Control Configuration per: https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-tools/version-control-metadata-navigation#map-your-visual-studio-team-services-project-to-your-local-model-store-and-projects-folder | |
| ::Related discussion: https://community.dynamics.com/ax/f/33/t/229735 | |
| pushd "K:\AosService\PackagesLocalDirectory\Bin" | |
| SCDPBundleInstall.exe -prepare -packagepath="C:\XppPackages\HotfixPackageBundle.axscdppkg" -metadatastorepath="K:\AosService\PackagesLocalDirectory\Metadata" -tfsworkspacepath="K:\AosService\PackagesLocalDirectory\Metadata" -tfsprojecturi="https://mytenant.visualstudio.com" | |
| ::NB: The TFSWorkspace path points to the METADATA (i.e. is the same as we used for metadatastorepath); not the PROJECT (e.g. C:\Users\User123abcdef\Documents\Visual Studio 2015\Projects) |