Author Archives: JAB_au

Export List of Office 365 Licenses by Type

It’s possible to to use Powershell to export lists of users who are allocated different licences in Office 365. This guide will help you export a csv file that contains a list of the users who have a specific license type.

Part 1 – Connecting to Office 365 with Powershell

  1. First open a powershell console enter the following:
    $UserCredential = Get-Credential
  2. You will be prompted for your Office 365 username and password
  3. Now we must establish a conenction using the stored credentials:
    Connect-MsolService -Credential $UserCredential
  4. Now that you are connected to Office 365’s powershell interface you can now issue commands to Office 365.

Part 2 – Listing Licences in your account

Enter the command:

Get-MsolAccountSku

This will display a list of licences and the number of each you own and are utilised.

AccountSkuiD: <instancename>:<licencename>
ActiveUnits: The number of licences available based on your subscription
WarningUnits: Licenses in warning state
ComsumedUnits: Licenses in use and assigned to users.

Part 3 – Exporting the Data for a specific Licenes Type

Enter the following command, this will export a list of users with Power BI Standard license assigned to them. Remember to change <instancename> to match the instance name displayed in your output from part 2.

get-MSOLUser -All | where {$_.isLicensed -eq "TRUE" -and $_.Licenses.AccountSKUID -eq "<instancename>:POWER_BI_STANDARD"} | select displayname,userprincipalname,isLicensed | export-CSV c:\crmstandardusers.csv

You will now have a CSV file containing a list of the users with the specified license. You can perform this with any licenses listed from the Get-MsolAccountSku command.

Enable Strict Transport Security on IIS

The following is a guide to enable Strict Transport Security on IIS (Internet Information Server).

Open up IIS Manager and navigate to the the Server Name

Select HTTP Responce

Click on Add, and enter the values as follows

Click ok and then click on the server name again, select the restart option from the actions pane.

You server should now pass Qualys SSL Test for Strict Transport Security.

Provision Windows Store Apps for Windows 10 Imaging

When building fat Windows 10 Images it is necessary to sometimes install Windows Store apps, however you can’t just install them from the standard Windows Store, doing so will cause sysprep to fail. At no point should you try to run any Windows store apps when building an image.

DISM can be used to provision the app for all users in your image. The following is an example command using Microsoft Reader, it’s dependance of Microsoft VCLibs and finally it’s licence file:

Dism /Online /Add-ProvisionedAppxPackage /PackagePath:Microsoft.Reader_2017.612.315.3642_neutral_~_8wekyb3d8bbwe.AppxBundle /DependencyPackagePath:Microsoft.VCLibs.120.00_12.0.21005.1_x64__8wekyb3d8bbwe.Appx /LicensePath:Microsoft.Reader_8wekyb3d8bbwe_e5086f30-ff13-cf16-91fb-0cc6ed9c5613.xml

To obtain the app files you must download them from the Microsoft Windows Store for Business. Sign in with a user account and find the package you are looking for.

Once you have found the app you’re looking for select offline for the licence type.

Click Manager, then no the next screen click Get App.

Now Select your Processor architecture, if 32 bit windows select x86, for 64 bit select X64, Finally select your language. Ignore the Download button at the end of the line this will download a JSON file not required for this process.

Scroll down and click the Download link under “Download the package for offline use”, this will download the Package for Reader.

The next link down the page is the licensing file for Offline install, download this preferably to the same location.

Finally after the licence link you will see “Required frameworks”, this of course depends on the app you are trying to download, these may be architecture dependent also. Download these files into the same location as well.

Once you have all the files in a single folder or location open a command prompt or powershell window with administrator privileges and change directory to the location of your downloaded files from the Windows Store.

Execute the DSIM command like the following:

Dism /Online /Add-ProvisionedAppxPackage /PackagePath:PackageFileName /DependencyPackagePath:DependencyPackageFileName /LicensePath:LicenceFilename

Once this as executed the package will install for all users, and your windows image will seal correctly.

TechNet – DISM App Package (.appx or .appxbundle) Servicing Command-Line Options

Get the Number of Mailboxes in Office 365

The following is a quick guide on how to get a count of the number of mailboxes in Office 365 for user mailboxes, room mailboxes and shared mailboxes.

Open an administrator powershell

$UserCredential = Get-Credential

The above command should trigger a prompt for a username and password, enter the details of an Office 365 administrator.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/-Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

Now use one of the following commands in powershell:
Retrieve number of user mailboxes:

(Get-Recipient -RecipientTypeDetails usermailbox -ResultSize Unlimited).count

Retrieve number of shared mailboxes:

(Get-Recipient -RecipientTypeDetails sharedmailbox -ResultSize Unlimited).count

Retrieve number of room mailboxes:

(Get-Recipient -RecipientTypeDetails roommailbox -ResultSize Unlimited).count

Upgrade Windows 10 Home to Windows 10 Pro

From your Windows 10 Home running Version 1511, enter the Windows 10 Pro Default key under change product key.

VK7JG-NPHTM-C97JM-9MPGT-3V66T

This default key will not activate the system, just take you to Pro so you can activate using a valid Pro key that you will provide.

Once you have done this, the system will go through an upgrade process from Home to Pro, but will not be activated on Pro.

You will require a genuine product key to then activate Windows.

Compressing Individual Files Into individual Archives Using 7-Zip Command Line

The following will allow you to compress all the individual files in a folder to each be inside their own archive / folder.

Prerequisites / Requirements

Install 7-Zip, available at http://www.7-zip.org/

Set the environment PATH variable to include the 7-Zip folder path where the application is installed. e.g. C:\Program Files\7-Zip

The Command

FOR %i IN (*.*) DO 7z.exe a "%~ni.7z" "%i"

Explanation of each variable:

  • %i is a variable that holds the file name for each step in the loop
  • (*.*) is the selection criteria, it could easily be *.exe or similar
  • 7z.exe is the command line version of 7-Zip
  • %~ni – this expands the %i variable to just the file name – no extension

By default 7z will use it’s own file format, you can modify the command as follows to create zip (WinZIP / WIndows Compressed Folders) compatible files.

FOR %i IN (*.*) DO 7z.exe a -tzip "%~ni.zip" "%i"

Bitcoin Console Commands

== Blockchain ==
getbestblockhash
getblock “blockhash” ( verbose )
getblockchaininfo
getblockcount
getblockhash height
getblockheader “hash” ( verbose )
getchaintips
getdifficulty
getmempoolancestors txid (verbose)
getmempooldescendants txid (verbose)
getmempoolentry txid
getmempoolinfo
getrawmempool ( verbose )
gettxout “txid” n ( include_mempool )
gettxoutproof [“txid”,…] ( blockhash )
gettxoutsetinfo
preciousblock “blockhash”
pruneblockchain
verifychain ( checklevel nblocks )
verifytxoutproof “proof”

== Control ==
getinfo
getmemoryinfo
help ( “command” )
stop

== Generating ==
generate nblocks ( maxtries )
generatetoaddress nblocks address (maxtries)

== Mining ==
getblocktemplate ( TemplateRequest )
getmininginfo
getnetworkhashps ( nblocks height )
prioritisetransaction <txid> <priority delta> <fee delta>
submitblock “hexdata” ( “jsonparametersobject” )

== Network ==
addnode “node” “add|remove|onetry”
clearbanned
disconnectnode “node”
getaddednodeinfo ( “node” )
getconnectioncount
getnettotals
getnetworkinfo
getpeerinfo
listbanned
ping
setban “subnet” “add|remove” (bantime) (absolute)
setnetworkactive true|false

== Rawtransactions ==
createrawtransaction [{“txid”:”id”,”vout”:n},…] {“address”:amount,”data”:”hex”,…} ( locktime )
decoderawtransaction “hexstring”
decodescript “hexstring”
fundrawtransaction “hexstring” ( options )
getrawtransaction “txid” ( verbose )
sendrawtransaction “hexstring” ( allowhighfees )
signrawtransaction “hexstring” ( [{“txid”:”id”,”vout”:n,”scriptPubKey”:”hex”,”redeemScript”:”hex”},…] [“privatekey1”,…] sighashtype )

== Util ==
createmultisig nrequired [“key”,…]
estimatefee nblocks
estimatepriority nblocks
estimatesmartfee nblocks
estimatesmartpriority nblocks
signmessagewithprivkey “privkey” “message”
validateaddress “address”
verifymessage “address” “signature” “message”

== Wallet ==
abandontransaction “txid”
addmultisigaddress nrequired [“key”,…] ( “account” )
addwitnessaddress “address”
backupwallet “destination”
bumpfee “txid” ( options )
dumpprivkey “address”
dumpwallet “filename”
encryptwallet “passphrase”
getaccount “address”
getaccountaddress “account”
getaddressesbyaccount “account”
getbalance ( “account” minconf include_watchonly )
getnewaddress ( “account” )
getrawchangeaddress
getreceivedbyaccount “account” ( minconf )
getreceivedbyaddress “address” ( minconf )
gettransaction “txid” ( include_watchonly )
getunconfirmedbalance
getwalletinfo
importaddress “address” ( “label” rescan p2sh )
importmulti “requests” “options”
importprivkey “bitcoinprivkey” ( “label” ) ( rescan )
importprunedfunds
importpubkey “pubkey” ( “label” rescan )
importwallet “filename”
keypoolrefill ( newsize )
listaccounts ( minconf include_watchonly)
listaddressgroupings
listlockunspent
listreceivedbyaccount ( minconf include_empty include_watchonly)
listreceivedbyaddress ( minconf include_empty include_watchonly)
listsinceblock ( “blockhash” target_confirmations include_watchonly)
listtransactions ( “account” count skip include_watchonly)
listunspent ( minconf maxconf [“addresses”,…] [include_unsafe] )
lockunspent unlock ([{“txid”:”txid”,”vout”:n},…])
move “fromaccount” “toaccount” amount ( minconf “comment” )
removeprunedfunds “txid”
sendfrom “fromaccount” “toaddress” amount ( minconf “comment” “comment_to” )
sendmany “fromaccount” {“address”:amount,…} ( minconf “comment” [“address”,…] )
sendtoaddress “address” amount ( “comment” “comment_to” subtractfeefromamount )
setaccount “address” “account”
settxfee amount
signmessage “address” “message”

Test Phone Lines on NEC SV8100

How to test the individual phone lines on an NEC SV8100 phone system

  • Press the Speaker button
  • dial #0
  • dial 01, 01 corresponds to the first phone line on the system

Each following line is 02, 03, 04 etc. depending on how many lines attached to the system. I frequently feel phone system documentation is hard to find online especially things to do basic testing like this.

cab_XXXX Files in your C:\Windows\Temp Folder

You may have noticed the Windows TEMP folder filling up with cab_XXX files on systems, probably more servers than anything. It appears that makecab.exe is trying to zip CBS log files in the C:\Windows\Logs\CBS folder, these files can be rather large and for some reason it’s unable successfully complete the operation, so it creates this cab file instead… every 30 minutes.

The only solution i’ve been able to find is to run the following two commands to clean up the files, the second line will remove the CbsPersist files that makecab.exe is trying to compress:

cmd.exe /c del C:\Windows\Temp\*cab* /Q
cmd.exe /c del C:\Windows\Logs\CBS\*CbsPersist* /Q

Run Python Script in Background at Startup

The easiest way to do this is to run the script using crontab, but I would advise testing you script well first as you could make a script that causes problems.

$ crontab -e

and add the line:

@reboot /home/vivek/bin/python_script.py

Save and close, and then run

# update-rc.d cron defaults

Once you reboot the script will start automatically.