Skip to content

Instantly share code, notes, and snippets.

View D4R4's full-sized avatar

Dara Ardalan D4R4

  • SCALINX
  • Paris, France
View GitHub Profile
@D4R4
D4R4 / dynamics365
Created October 24, 2021 19:49
OnOptionsetChange: Get OptionSet value, add N days + the days until the end of the month and set to another field
function SetDueDate(executionContext) {
var obj = Xrm.Page.getAttribute("paymenttermscode");
if (obj != null) {
var created_date = Xrm.Page.getAttribute("createdon");
if (created_date != null) {
var optionSetValue = obj.getValue();
if (optionSetValue == "100000000") {
var new_date = addDays(created_date.getValue() ,60);
new_date = addDays(new_date,getMonthDaysLeft(new_date));
Xrm.Page.getAttribute("duedate").setValue(new_date);
@D4R4
D4R4 / dynamics.txt
Created October 24, 2021 14:34
Dynamics 365 - Hidden relationship and mapping - Opportunity line - Quote line - Order line
Step:1 Get entity relationship mapping id - replace source & target entity schema to desired entities you want
Add organization url/XRMServices/2011/OrganizationData.svc/EntityMapSet?$select=EntityMapId&$filter=SourceEntityName%20eq%20%27quotedetail%27%20and%20TargetEntityName%20eq%20%27salesorderdetail%27
To get Opportunity Products and Quote Products mapping id replace (source) opportunityproduct & (target) quotedetail this brings up the mapping id
Image
Step 2
@D4R4
D4R4 / fonts.sh
Created October 19, 2021 23:24
Install Windows fonts on CentOS
yum install rpm-build cabextract ttmkfdir
wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec
rpmbuild -bb msttcorefonts-2.5-1.spec
cp ~/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm /tmp
yum install /tmp/msttcorefonts-2.5-1.noarch.rpm
fc-cache /usr/share/fonts
@D4R4
D4R4 / dynamics_addDays_field.js
Created October 13, 2021 20:05
Take date form field value and add days to it. Dynamics 365 Web Resource
function addDays(date, days) {
var result = new Date(date);
result.setDate(result.getDate() + parseInt(days));
return result;
}
function recalculateDateFieldValue() {
var date= Xrm.Page.getAttribute("effectivefrom").getValue();
if (date != null) {
@D4R4
D4R4 / edgerouter
Created August 26, 2021 16:51
Remove conntrack log to force reset failover interface connections, resolving IPSec connectivity issue in cases where Active/Passive failover switches back
clear connection-tracking
@D4R4
D4R4 / manual_xauth_token.sh
Created July 16, 2021 08:59
Reapply X Window xauth token to allow for GUI apps to open when 'su' as another user
# xauth list $DISPLAY
node01.tester.com/unix:10 MIT-MAGIC-COOKIE-1 dacbc5765ec54a1d7115a172147866aa
# echo $DSIPLAY
localhost:10.0
# sudo su - [user]
# xauth add node01.tester.com/unix:10 MIT-MAGIC-COOKIE-1 dacbc5765ec54a1d7115a172147866aa
# export DISPLAY=localhost:10.0
# xclock
@D4R4
D4R4 / Mail_old_passwords.ps1
Last active August 8, 2021 22:23
POWERSHELL Send an email to admin regarding users with old passwords
Import-Module ActiveDirectory
$today = Get-Date
$checkDate = $today.Date.AddDays(-350)
Try
{
$results = Get-ADUser -Filter {Memberof -eq "CN=company,OU=Groups,DC=company,DC=net"} -properties passwordlastset -SearchBase "CN=Users,DC=company,DC=net" | Where-Object {$_.passwordlastset -lt $checkDate}
$results_string = $results | Sort-Object -property passwordlastset | Format-Table Name, passwordlastset -HideTableHeaders | Out-String
@D4R4
D4R4 / Check_LastPasswdChange
Created June 17, 2021 11:43
Powershell scripts to list and sort users by their last password change on-premise and AzureAD
Get-ADUser -Filter * -properties passwordlastset -SearchBase "CN=Users,DC=local,DC=net" | Sort-Object -property passwordlastset | ft Name, passwordlastset
Connect-MsolService
Get-MsolUser -All | Select DisplayName,UserPrincipalName,LastPasswordChangeTimeStamp | Sort-Object -property LastPasswordChangeTimeStamp
@D4R4
D4R4 / Sync-AzureADSync
Created June 17, 2021 09:23
Force manual sync AzureAD sync Delta/Initial
# open a privileged powershell
Import-Module ADSync
Get-ADSyncScheduler
# delta sync
Start-ADSyncSyncCycle -PolicyType Delta
# or full sync
Start-ADSyncSyncCycle -PolicyType Initial
@D4R4
D4R4 / sub_unsub_m365.ps1
Created December 7, 2020 17:26
subscribe/unsusbcribe Microsoft 365 group members to mails and events
Get-UnifiedGroupLinks -Identity GROUP -LinkType Subscribers
Add-UnifiedGroupLinks -Identity GROUP -LinkType Subscribers -Links user@email.com
Remove-UnifiedGroupLinks -Identity GROUP -LinkType Members -Links laura@contoso.com,julia@contoso.com