After logging to azure (az login) when tried to list Resource groups, was getting: Resource group could not be found.

I’m owner of subscription where resource group is located. Quick google search suggested

az group show -g kubernetes-learning --subscription "111-222-333-444-555"

But it didn’t help.

az account show command

Showed different “default” subscription

After setting subscription where resource group is located, as default, finally got rid of error

az account set --subscription "111-222-333-444-555"

Google and Microsoft are planning to deprecate Basic Authentication, as a response, Atlassian offer OAuth2 authentication.Please note that JIRA URL needs to be accessible from the internet so Azure can contact Jira.

Creating Azure Application registration

  1. In Azure portal go to Active Directory – App registrations – New registration

2.Type name,Account type:Accounts in any organizational directory (Any Azure AD directory – Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox) – click register

3.Copy Application (client) ID to notepad (will be used later on)

4. Click Api Permissions – Microsoft Graph – Add permissions – Delegated permissions

Add following permissions:

OpenId permissions: offline_access
IMAP: IMAP.AccessAsUser.All
POP: POP.AccessAsUser.All

Click “Grant admin consent”

5. Click Certifcates & Secrets – New Client Secret – Give name and set validity period – Copy secret to notepad

JIRA configuration

6.Log in to Jira – System – OAuth2 – Add new integration

Provider:Microsoft:

Client ID: from step 3

Secret: from step 5

Scopes: https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/POP.AccessAsUser.All and offline_access

Copy redirect URL

7. Go back to Azure app registration created in step 1 – Overview – Add a Redirect URI

Add platform – Web

Paste URL from step 6

Go back to JIRA and click Test connection,

if successfull:

8. Navigate to Administration > System > Incoming Mail

Click on Add mail server
At the “Service Provider” field, let’s pick up Microsoft Exchange Online / Outlook (IMAP)
At the “Username” field, insert the email address being used by Jira
At the “Authentication method” field, select the new server created under the OAuth 2.0 menu
Click on Authorize
Click on Test Connection
Click on Save

If test fails turn on debug logs

9.Navigate to Administration > System > Logging and profiling

Under “Default Loggers” section, click on Configure logging level for another package

  • At the “Package name” field, insert com.atlassian.jira.mail.settings.MailSetting
  • At the “Logging Level” dropdown, select DEBUG
  • Click on Add
  • Under “Default Loggers” section, click on Configure logging level for another package
  • At the “Package name” field, insert com.atlassian.plugin.remotable.plugin.module.oauth.OAuth2LOAuthenticator
  • At the “Logging Level” dropdown, select DEBUG
  • Click on Add
  • Replicate the issue

Create support.zip file

From support.zip file, open atlassian-jira.log file and check for errors

Adding shared mailboxes

If Jira is using shared mailboxes, delegate full control over mailbox to email account.

Add new email server in JIRA, specify shared mailbox username – click Authorize and then specify delegated email credentials

Exchange server SSL certificate was about to expire,in Exchange control panel created Certificate request

Created Certificate request, purchased new cert and after importing it, i still was seeing “Pending request” instead of new certificate.

Cert was installed in Local machine personal store but without private key (missing “key” icon)

Obtained SSL cert serial number

Created new private key for SSL certificate

certutil -repairstore my "4efaf9cf77fe59a448506e8a92a2b941"

Also, noted cert had no friendly name, so had to create it too:

Get Cert thumbprint:

(Get-ChildItem -Path Cert:\LocalMachine\My\<The thumbprint of your certificate>).FriendlyName = 'exchange.example.com'

(Get-ChildItem -Path Cert:\LocalMachine\My\e3c38169c22034de908e59c86171aa23c6ad01cc).FriendlyName = 'exchange.example.com'

After refreshing Exchange control panel, certificate finally appeared, with friendly name, now what’s left was to activate new cert

Enable-ExchangeCertificate –Thumbprint e3c38169c22034de908e59c86171aa23c6ad01cc –Services "IIS, SMTP, POP, IMAP"

Now delete old certificate, after testing access https://exchange.example.com/owa, in web browser i still saw old cert, had to restart IIS service to see new certificate.

File 1.csv:

ServerName
Server1
Server2
Server3

This code will “load” this file into PowerShell form and will output selected value into variable

###################Load Assembly for creating form & button######
 
[void][System.Reflection.Assembly]::LoadWithPartialName( "System.Windows.Forms")
[void][System.Reflection.Assembly]::LoadWithPartialName( "Microsoft.VisualBasic")
 
 
#####Define the form size & placement
 
$form = New-Object "System.Windows.Forms.Form";
$form.Width = 500;
$form.Height = 190;
$form.Text = $title;
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen;
$form.ControlBox = $True
 
 
##############Define text label2
 
$textLabel2 = New-Object "System.Windows.Forms.Label";
$textLabel2.Left = 25;
$textLabel2.Top = 80;
 
$textLabel2.Text = $WF;
 
 
############Define text box2 for input
 
$cBox2 = New-Object "System.Windows.Forms.combobox";
$cBox2.Left = 150;
$cBox2.Top = 80;
$cBox2.width = 200;
 
 
###############"Add descriptions to combo box"##############

import-csv "C:\Users\Komp\Desktop\1.csv" | ForEach-Object {
    $cBox2.Items.Add($_.ServerName)
     
}
 
 
#############define OK button
$button = New-Object "System.Windows.Forms.Button";
$button.Left = 360;
$button.Top = 45;
$button.Width = 100;
$button.Text = “Ok”;
$Button.Cursor = [System.Windows.Forms.Cursors]::Hand
$Button.Font = New-Object System.Drawing.Font("Times New Roman",12,[System.Drawing.FontStyle]::BOLD)
############# This is when you have to close the form after getting values
$eventHandler = [System.EventHandler]{
$cBox2.Text;
$form.Close();};
$button.Add_Click($eventHandler) ;
 
#############Add controls to all the above objects defined
$form.Controls.Add($button);
$form.Controls.Add($textLabel2);
$form.Controls.Add($cBox2);
#$ret = $form.ShowDialog();
 
#################return values
$button.add_Click({
     
    #Set-Variable -Name locationResult -Value $combobox1.selectedItem -Force -Scope Script # Use this
    $script:locationResult = $cBox2.selectedItem # or this to retrieve the user selection
})
 
$form.Controls.Add($button)
$form.Controls.Add($cBox2)
 
$form.ShowDialog()
 
$output = $script:locationResult

Combo box values different from Displayed values

Let’s say we want do display in GUI one value, but real output value is something different, for example

In form we want to show Country code (Serbia), but actual value is Code (SRB)

1.csv:

Country, Code
Serbia, SRB
Germany, DE
Russia, RU

I’ll show just what’s changed:

###############"Add descriptions to combo box"##############

$input = import-csv "C:\Users\Komp\Desktop\1.csv"
$cBox2.DisplayMember = 'Country'
    $input | ForEach-Object {
    $cBox2.Items.Add($_)
}

#################return values
$button.add_Click({
     
    #Set-Variable -Name locationResult -Value $combobox1.selectedItem -Force -Scope Script # Use this
    $script:locationResult = $cBox2.selectedItem.Code # or this to retrieve the user selection
    
})

Output will be SRB

This script will list all enabled AD users, user Name, DN,LastLogonDate, User Description, Group user is member of, as well as Group description and group type

Get-AdGroup -Filter * -Properties *  -PipelineVariable g | 
    Get-AdGroupMember |
    where{$_.ObjectClass -eq 'User'} | 
    Get-AdUser -Properties * | 
    Where{$_.Enabled} |
    select @{n='GroupName';e={$g.Name}}, @{n='GroupDescription';e={$g.Description}}, @{n='GroupType';e={$g.groupcategory}}, Name, DistinguishedName, Description, LastLogonDate | export-csv "C:\1.csv" -NoTypeInformation -Encoding UTF8
    sort GroupName, Name

Extend boot partition as part of Volume group

Initial disk size is 20 GB

Check it with fdisk -l command

Partition size – df -h

I extended disk to 40 GB

If new size is not automatically expanded, scan SCSI devices, first list all SCSI devices

ls /sys/class/scsi_device/
2:0:0:0  3:0:0:0  32:0:0:0

And scan all devices individually

echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
echo 1 > /sys/class/scsi_device/3\:0\:0\:0/device/rescan
echo 1 > /sys/class/scsi_device/32\:0\:0\:0/device/rescan

Use cfdisk to extend boot partition,select it, (/dev/sda3 in my case) and select “Resize”

Click enter, new size is shown

Then select “Write”, when prompted, type “Yes”, and then select “Quit” and press Enter

With fdisk -l /dev/sda, make sure partition is extended

Next, let’s run parted and resize a partition

parted
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  1076MB  1074MB  ext4
 3      1076MB  42.9GB  41.9GB

(parted) resizepart
Partition number? 3
End?  [42.9GB]?
(parted) quit
Information: You may need to update /etc/fstab.

Next, resize the physical volume:

pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Now, extend the logical volume:

lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <19.00 GiB (4863 extents) to <39.00 GiB (9983 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.

Finally, run resize2fs to apply the changes:

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 5
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 10222592 (4k) blocks long.

Verify changes: df -h, partition is extended from 20 to 40 GB

Extend boot partition as NOT part of Volume group

First, detect root partition with df -h

In this example i expanded disk for 10 GB, so total size is 20+10=30 GB

Run again cfdisk and select boot partition (/dev/sda2 in my case) and select “Resize”

Click Enter,select “Write”, and they type “Yes” and then select “Quit” and press Enter

Make sure disk is extended

Now, we just need to resize filesystem

resize2fs /dev/sda2
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 4
The filesystem on /dev/sda2 is now 7863803 (4k) blocks long.

Now, check partition is extended from 20 to 30 GB

Recently, i had to get a list of computers where specific folder exists, if you need to search all computers just remove filter 'operatingsystem -notlike "server"'.

Script will output machines name where folder/file exists

Try{
    $computers = Get-ADComputer -Filter 'operatingsystem -notlike "*server*" -and enabled -eq "true"' `
    -Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address |
    Select-Object -ExpandProperty Name

    foreach ($Computer in $computers) {
    if(Test-Path "\\$Computer\c$\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin"){

    Write-Output $Computer
    }
  }
}
Catch{
     Write-Warning $Error[0]
}

This script searches Microsoft Partner Center’s all tenants for specific user. It takes 2 parameters:

$userName – it’s User’s display name in Partner Center

$csvPath – Path for report file

# Bellow 2 commented commands are required only once

# Install-Module -Name PartnerCenter -AllowClobber
# Import-Module PartnerCenter 
# Connect to partner center 
Connect-PartnerCenter

Function Get-User-From-PartnerCenter {
[cmdletbinding()]
Param (
[parameter(Mandatory=$true)]
[string]$csvPath,
[string]$userName
)
# End of Parameters
 Process {
         $Result = ""   
         $Results = @() 
         $ErrorActionPreference = "Stop"

         # Get all tenats in Partner center

         $Customers = Get-PartnerCustomer

         # Search every tenant for specific user

         $Customers.ForEach({

         Try{
                $CustId = $_.CustomerId
                $CustName = $_.Name
                $CustomerUser = Get-PartnerCustomerUser -CustomerId $CustId | Where-Object {
                $_.DisplayName -like "*$userName*"
                } | ForEach-Object { New-Object -TypeName PSCustomObject -Property @{
                Name = $_.DisplayName
                'User Principal Name' = $_.UserPrincipalName
                }
               }
               
               # If user is found, Write it to CSV file

                if($CustomerUser -notlike ''){
                  $Result = @{'Customer Name' = $CustName; 'User Name' = $CustomerUser.Name; 'User Principal Name' = $CustomerUser.'User Principal Name'}
                  $Results += New-Object PSObject -Property $Result
                  $Results = $Results | Select-Object 'Customer Name','User Name','User Principal Name' | Export-Csv -Path $csvPath -Notype -append
                }
         }
            
         Catch{

               Write-Warning "Caught an exception:"
               Write-Warning "Exception Type: $($_.Exception.GetType().FullName)"
               Write-Warning "Exception Message: $($_.Exception.Message) - Tenant:$CustName"
          }
         }
       )
     }
    }

Usage:

Get-User-From-PartnerCenter -csvPath 'C:\Users\user\partnerCenter.csv' -userName "Tony Stark"

Recently, i needed to create list of all Office 365 subscriptions Get-MsolSubscription returns total number of purchased licenses and expiration date and Get-MsolAccountSku returns total and used licenses, but no expiry date, so i had to “join” these 2 command somehow

# declare variables for storing results
$Result=""   
$Results=@() 
#Get available subscriptions in the tenant 
$Subscriptions= Get-MsolSubscription | foreach{
 $SubscriptionName=$_.SKUPartNumber
 $SubscribedOn=$_.DateCreated
 $ExpiryDate=$_.NextLifeCycleDate
 $Status=$_.Status
 $TotalLicenses=$_.TotalLicenses
 # get number of assigned licences
 $consumedLicences = Get-MsolAccountSku | Where-Object {
        $_.SkuPartNumber -like $SubscriptionName
    } | ForEach-Object {
        $_.ConsumedUnits
    }
 # export to CSV
 $Result=@{'Subscription Name'=$SubscriptionName;'Total Licenses'=$TotalLicenses;'Used Licences'=$consumedLicences;'Expiry Date'=$ExpiryDate;'Status'=$Status}
 $Results+= New-Object PSObject -Property $Result
 $Results | Select-Object 'Subscription Name','Total Licenses','Used Licences','License Expiry Date','Status' | Export-Csv -Path $ExportCSV -Notype -Append  
  }

Filter is applied with Where-Object before doing anything else – while each output object from Get-MsolAccountSku still has it’s properties intact. Then we use ForEach-Object to extract the value of ConsumedUnits.

After terraform init, when trying to plan or deploy resources, terraform just hangs. On some Windows 10 machine it works fine, on other not.Terraform version v0.14.4

Debug logs returns following error: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/aws/

After some googling, found out that adding following environmental variable fixes the issue:GODEBUG=asyncpreemptoff=1

On windows, it can be added as User or system variable

On linux/MAC:

export GODEBUG=asyncpreemptoff=1