Skip to content

Instantly share code, notes, and snippets.

@jkbryan
jkbryan / powershellworkflow-send-mail-if-accountname-present.ps1
Created October 2, 2018 21:25
powershellworkflow-send-mail-if-accountname-present.ps1
$VerbosePreference = 'Continue'
$Global:ErrorActionPreference="Stop"
$error.clear()
if (-not $fimwf)
{
Throw "Failed to get workflow details from the FIM Target"
}
Write-Verbose "Processing FIM WF with TargetId: $fimwf"
###
@jkbryan
jkbryan / get-the-powershell-workflow-xoml.ps1
Created October 2, 2018 21:22
get-the-powershell-workflow-xoml.ps1
PS C:\FIMScripts\PowerShellWorkflow> $obj = Get-Resource -ObjectType WorkflowDefinition -AttributeName DisplayName -AttributeValue "___WF:PSWFTEST2"
PS C:\FIMScripts\PowerShellWorkflow> $obj
ClearRegistration :
CreatedTime : 02/11/2015 16:28:55
Creator : urn:uuid:7fb2b853-24f0-4498-9534-4e10589723c4
DeletedTime :
Description :
DetectedRulesList : {}
@jkbryan
jkbryan / mpr-disable-enable.ps1
Created October 2, 2018 21:20
mpr-disable-enable.ps1
$query=New-XPathQuery -AttributeName DisplayName -Operator StartsWith "__MPR:"
$Expression=New-XPathExpression -ObjectType "ManagementPolicyRule" -QueryObject $query
$AllMPRs=Search-Resources $Expression
ForEach ($MPR in $AllMPRs)
{
$Resource=Get-Resource -ObjectType ManagementPolicyRule -AttributeName ObjectID -AttributeValue $MPR.ObjectID
$Resource.Disabled = "True"
#$Resource.Disabled = "False"
Save-Resource $Resource
}
@jkbryan
jkbryan / getting-those-post-processing-requests.ps1
Created October 2, 2018 21:18
getting-those-post-processing-requests.ps1
Export-FIMConfig -OnlyBaseResources -CustomConfig "/Request[RequestStatus='Post Processing']" | Convert-FimExportToPSObject
@jkbryan
jkbryan / surname-hr-import.vb
Last active October 2, 2018 21:15
surname-hr-import.vb
Case "sn-HRMA-Import"
'HR attributes required are:Surname, AccountName
'Ensure that this attribute has spaced Hypens corrected
Dim surnamelogFileName As String = dtDateNowDay & "-" & dtDateNowMonth & "-" & dtDateNowYear & "_HRMA_Surname.log"
Logging.SetupLogFile(surnamelogFileName, loggingLevel)
If csentry("Surname").IsPresent Then
If csentry("Surname").Value.ToLower = "null" Then
mventry("sn").Delete()
If csentry("AccountName").IsPresent Then
Throw New Exception("Error in Surname (null) for FedID: " & csentry("AccountName").Value)
@jkbryan
jkbryan / connect-to-msol-using-the-stored-credential.ps1
Created October 2, 2018 21:08
connect-to-msol-using-the-stored-credential.ps1
#CredMan stuff
$sig = @"
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NativeCredential
{
public UInt32 Flags;
public CRED_TYPE Type;
public IntPtr TargetName;
public IntPtr Comment;
public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten;
@jkbryan
jkbryan / create-credential.ps1
Created October 2, 2018 21:05
create-credential.ps1
#CredMan stuff
$sig = @"
[DllImport("Advapi32.dll", SetLastError=true, EntryPoint="CredWriteW", CharSet=CharSet.Unicode)]
public static extern bool CredWrite([In] ref Credential userCredential, [In] UInt32 flags);
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct Credential
{
public UInt32 flags;
public UInt32 type;
public IntPtr targetName;
@jkbryan
jkbryan / auto-start-cpu.py-on-boot.txt
Created October 2, 2018 21:03
auto-start-cpu.py-on-boot.txt
nano /etc/systemd/system/cpu-py.service
Add:
[Unit]
Description=cpu piglow python script
After=syslog.target network.target
[Service]
ExecStart=/usr/bin/python /usr/share/piglow/cpu.py
@jkbryan
jkbryan / enable-piglow.txt
Created October 2, 2018 21:02
enable-piglow.txt
nano /boot/config.txt
Add:
device_tree_param=bcm2709-rpi-2-b.dtb
device_tree_param=i2c1=on
device_tree_param=spi=on
nano /etc/modules-load.d/raspberrypi.conf
Add: i2c-dev
pacman -Syu
@jkbryan
jkbryan / o365-licence-management.ps1
Created October 2, 2018 21:00
o365-licence-management.ps1
$ErrorActionPreference = "Stop"
$Error.Clear()
#####################################################
# Function to generate mail content for licencing errors
Function MailBody
{
$Exception=$error[0].Exception.Message
$Command=$error[0].InvocationInfo.Line
$StrBody="$Exception `r`r$Command `r`r##########################################################################################`r`r"
$Error.Clear()