Convert P12 to P8 certificate

Do you of some reason need to convert a P12 certificate to a P8 certificate?

This is how you can do that.

Step 1.

openssl pkcs12 -in certificate.p12 -out certificate.pem -clcerts -nokeys

Step 2

openssl pkcs12 -in certificate.p12 -out key.pem -nocerts -nodes

Step 3

openssl pkcs8 -topk8 -inform PEM -outform PEM  -in in.key -out out.pkcs8 -v1 PBE-MD5-DES

Get a list of Exchange mailbox with forwarding

Are you looking for a way to find out how to get hold of all mailbox that has forward in their mailbox and where it’s going?

Get-Mailbox | Where {($_.ForwardingSMTPAddress -ne $null) -or ($_.ForwardingAddress -ne $null)} | Select Name, ForwardingSMTPAddress, ForwardingAddress, DeliverToMailboxAndForward | format-Table -AutoSize

| format-Table -AutoSize, in the end, might not be needed, but for me I feel so much easier to read the information I get back when I can read the entire email address.

Default Domin Password Policy

Do you want to find out the default policy set up on your company?

You can use this PowerShell command you will get the Default Domin Password Policy

Get-ADDefaultDomainPasswordPolicy

The variable you will get back should look something like this, plus a value in the end of course

ComplexityEnabled :
DistinguishedName :
LockoutDuration :
LockoutObservationWindow :
LockoutThreshold :
MaxPasswordAge :
MinPasswordAge :
MinPasswordLength :
objectClass :
objectGuid :
PasswordHistoryCount :
ReversibleEncryptionEnabled :

Remove Azure Role Assignment

How to remove users Access Management from Top level

First, make user you have full access in azure,
Then go to Azure AD, then to Properties

Change from No to Yes
When this is done, you can run this PowerShell command

Remove-AzRoleAssignment -SignInName first.lastname@company.com -RoleDefinitionName "User Access Administrator" -Scope "/"

This will remove the user’s access from the top level.
Make sure your user account change back your access right.

Azure AD Threshold sync

Have you encountered the problem that you want to make more change than allowed or that you just wonder changes how to change Azure AD Sync Threshold?
This needs to be done on the server that has an Azure Sync client.


First to find out if there is one and what is the setup?
Get-ADSyncExportDeletionThreshold

If you want to disable this rule for some reason,
we strongly advise against it.
Disable-ADSyncExportDeletionThreshold

Then there nothing stopping if someone accidentally deleted to many accounts between two syncs.

If you want to change the Threshold to 10
Enable-ADSyncExportDeletionThreshold -DeletionThreshold 10

Read more about it

Powershell SMB

Windows Server 2012 R2 & 2016: PowerShell methods

Detect: SMB v1
Get-WindowsFeature FS-SMB1

Disable:
Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol

Enable:
Enable-WindowsOptionalFeature -Online -FeatureName smb1protocol

Detect: SMB v2/v3
Get-SmbServerConfiguration | Select EnableSMB2Protocol

Disable:
Set-SmbServerConfiguration -EnableSMB2Protocol $false

Enable:
Set-SmbServerConfiguration -EnableSMB2Protocol $true

Windows 8.1 and Windows 10: PowerShell method

Detect: SMB v1 Protocol
Get-WindowsOptionalFeature –Online –FeatureName SMB1Protocol

Disable:
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

Enable:
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

Detect: SMB v2/v3 Protocol
Get-SmbServerConfiguration | Select EnableSMB2Protocol

Disable:
Set-SmbServerConfiguration –EnableSMB2Protocol $false

Enable:
Set-SmbServerConfiguration –EnableSMB2Protocol $true

Read more about at Microsoft

Powershell mount drive

How to mount a drive in Powershell



$url = hostname
$folder = specific folder
$port = port nr
$username = account name
$pass = password

 

$connectTestResult = Test-NetConnection -ComputerName $url -Port $port
if ($connectTestResult.TcpTestSucceeded) {
    # Save the password so the drive will persist on reboot
    cmd.exe /C "cmdkey /add:`"$url`" /user:`"$username`" /pass:`$pass`""
    # Mount the drive
    New-PSDrive -Name Z -PSProvider FileSystem -Root "$folder"-Persist
} else {
    Write-Error -Message "Unable to reach the $url storage account via port $port. Check to make sure your organization or ISP is not blocking port $port"

}

Computer branding with PDQ

Hey
What do you say we give it a shot and try to do computer branding with PDQ?

Here you have a code you can try to experiment with.

More information about $location check out this post, there you can read how to fetch the information and import it into PDQ Inventory database.

$location = "where you want to store CSV file that PDQ will fetch from"
$localLocation "where you want to store local txt file"

#Featch Values
function MenuGui()
{
#To use the .NET functionality to create forms, we use the class System.Windows.Forms. To load this class into a PowerShell session, you can use the following code:
Add-Type -assembly System.Windows.Forms

#Now create the screen form (window)
$main_form = New-Object System.Windows.Forms.Form

#Set the title and size of the window:
$main_form.Text ='Helpdesk'
$main_form.Width = 400
$main_form.Height = 50

#To make the form automatically stretch, if the elements on the form are out of bounds, we use the AutoSize property.
$main_form.AutoSize = $true

#Create a label element on the form about user name
$Label = New-Object System.Windows.Forms.Label
$Label.Text = "User: " + $WhoAmI
$Label.Location  = New-Object System.Drawing.Point(150,10)
$Label.AutoSize = $true
$main_form.Controls.Add($Label)

#Create a secound label element on the form about computer name
$Label2 = New-Object System.Windows.Forms.Label
$Label2.Text = "Computer name: " + $Hostname  
$Label2.Location  = New-Object System.Drawing.Point(150,25)
$Label2.AutoSize = $true
$main_form.Controls.Add($Label2)

  # Add Button 1
    $Button = New-Object System.Windows.Forms.Button
    $Button.Location = New-Object System.Drawing.Size(150,45)
    $Button.Size = New-Object System.Drawing.Size(145,23)
    $Button.Text = "Change Owner"
    $main_form.Controls.Add($Button)
  
  #Add close form function to the button, when you click
        $Button.add_click({
        $employees = @($Hostname+","+$WhoAmI)
        $employees | foreach { Add-Content -Path $locationv -Value $_ }
        New-Item -Path $localLocation\ -Name "Owner.txt" -ItemType "file" -Value $env:UserName -Force
        $main_form.Close()})

    
#Create a label element on the form about user name
$Label3 = New-Object System.Windows.Forms.Label
$Label3.Text = "You get this message for our systems says someone else is the owner of this computer`n then the user who is logged in. Please press Change Owner if its incorrect`n`nIf any question contact us on Phone: XXX, Email: xxx@xxx.com "
$Label3.Location  = New-Object System.Drawing.Point(1,80)
$Label3.AutoSize = $true
$main_form.Controls.Add($Label3)
  

#Now you can display the form on the screen.
$main_form.ShowDialog()
}

#Variable
$Hostname = $env:COMPUTERNAME
$WhoAmI = $env:UserName


$WantFile = "$localLocation\Owner.txt"
$FileExists = Test-Path $WantFile
If ($FileExists -eq $True) 
{
    Write-Host "Yippee file exist"
}

Else 
{
    New-Item -Path $localLocation\ -Name "Owner.txt" -ItemType "file" -Value $env:UserName -Force
    $employees = @($Hostname+","+$WhoAmI)
    $employees | foreach { Add-Content -Path $location -Value $_ }
    Write-Host "NO! File do not exist"
}


$textfile = Get-Content -Path $localLocation\Owner.txt

if($textfile -eq $env:UserName)
{
  echo "True value, do not run the script";
}
else
{
    echo "wrong value, please run the script";
    MenuGui
}

Enjoy!


Import data to PDQ Inventory

Do you have external data you want to import to PDQ Inventory?

With the help of this PHP code, you can do this.


$TempFile = "specify where the file is located"
$Computer = "Name"
$CustomFieldName = "Owner"
$CustomFieldType = "String" # Valid types - Boolean, String, Integer, Date, or DateTime
PDQInventory.exe ImportCustomFields -FileName $TempFile -ComputerColumn $Computer -CustomFields "$CustomFieldName=$CustomFieldName" -AllowOverwrite

A good place to find help is PDQ Community

Windows search index is down

Hi
So are you or someone you know affected by the Windows search index has stopped working?
There are a few ways to solve this.

If you want to try to solve this with Powershell you need to download a file from Microsoft
You might need to change Powershell Policy not sure

If you do not want to use Powershell scroll down

Start with scroll down and try to find Windows Powershell

Windows Powershell folder


The look for Windows Powershell ISE (I prefer that one)
But it has to be open as Administrator

Windows Powershell ISE as administrator


When you run the file, you will receive message pick Run Once
If you get an error message as image below, then you cant runt Windows Powershell ISE

Exception calling “ReadKey” with 1 is not implemented


Then you need to pick regular PowerShell, but you still need to run it as Administrator.

Windows Powershell run as administrator


You will get a message again, pick R, for Run once

Prompt message when you run the script


After that, the Windows search index should work again.

Is it still a problem with Search Index or did not want to use Powershell try this.


Source to solve this without Powershell
· Hit the Windows Key + R shortcut on your keyboard.
· Type Regedit and hit Enter on your keyboard.
· Double-click HKEY_CURRENT_USER.
· Double-click SOFTWARE.
· Double-click Microsoft.
· Double-click Windows.
· Double-click CurrentVersion.
· Double-click Search.
· Right-click the right pane of the RegEdit window to bring up the menu.
· Click New.
· Click D-WORD (32-bit) Value.
· Type BingSearchEnabled and hit Enter on your keyboard.
· Double-click the BingSearchEnabled entry you just created.
· Type 0 in the Value data field. (It should already be 0 but make sure).
· Click on OK.
· Double-click CortanaConsent.
· Type 0 in the data field. (It should also already be 0 but make sure).
· Click on OK.
· Restart your PC

After that Windows search index should work again.