Posts Tagged ‘powershell’

Recently trying to install a Module in Powershell gallery on a PC , but came back with an error

PS C:\Windows\system32> Install-Module -Name AsBuiltReport
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'AsBuiltReport'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\\PSModule.psm1:1772 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Had a check and No Repos were listed

PS C:\Windows\system32> Get-PSRepository | fl *
WARNING: Unable to find module repositories.

Installed the Default Repos again

PS C:\Windows\system32> Register-PSRepository -Default
PS C:\Windows\system32> Get-PSRepository | fl *

Name : PSGallery
SourceLocation :
Trusted : False
Registered : True
InstallationPolicy : Untrusted
PackageManagementProvider : NuGet
PublishLocation :
ScriptSourceLocation :
ScriptPublishLocation :
ProviderOptions : {}Y
GD Star Rating
GD Star Rating

Open Powershell As Administrator

Import-Module NTFSSecurity

#Check Existing Access

dir2 “\\?\e:\folde\path\name” -Recurse | Get-NTFSAccess

#Take Ownership

dir2 “\\?\e:\folde\path\name” -Recurse | Set-NTFSOwner -Account “Administrators”

#Add Permissiosn

dir2 “\\?\e:\folde\path\name” -Recurse | Add-NTFSAccess -Account Administrators -AccessRights FullControl

#recheck Access

dir2 “\\?\e:\folde\path\name” -Recurse | Get-NTFSAccess

Prove access for a user

Get-ChildItem -Path c:\docs -Recurse -Directory | Get-NTFSEffectiveAccess -Account ‘corp\confroom’ | select Account, AccessControlType, AccessRights, FullName

GD Star Rating
GD Star Rating

You can send emails via Mimecast instead of 365 , so you don’t need a licensed 365 user.

Login and enable SMTP Email submissions for that user

Use the users Cloud password and email address for Auth

$creds = get-credential

Send-MailMessage -From [email protected] -To [email protected] -Subject "Test Email" -Body "Test SMTP Service from Powershell on Port 587" -SmtpServer -Credential $creds -UseSsl -Port 587


If you see

Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed

You need to create an Authentication profile with 2fa disabled , and apply it to that user via Application Settings


“Send-MailMessage : A call to SSPI failed, see inner exception”

Trying to send email comes back with this error , you need to change TLS1.2

‘ServicePointManager.SecurityProtocol’ is not recognized as the name

Trying to use

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
to Force TLS 1.2 doesn’t work 
# Enable TLS 1.2 as Security Protocol
[Net.ServicePointManager]::SecurityProtocol = `
    [Net.SecurityProtocolType]::Tls12 ;
GD Star Rating
GD Star Rating

You can target the following powershell below to update items in desktop-config.json such as 


(Get-Content $ENV:APPDATA\Microsoft\Teams\desktop-config.json).replace(‘”disableGpu”:false’, ‘”disableGpu”:true’) | Set-Content $ENV:APPDATA\Microsoft\Teams\desktop-config.json
(Get-Content $ENV:APPDATA\Microsoft\Teams\desktop-config.json).replace(‘”openAtLogin”:true’, ‘”openAtLogin”:false’) | Set-Content $ENV:APPDATA\Microsoft\Teams\desktop-config.json


GD Star Rating
GD Star Rating

 Report % Rate of change from the last Backup Job Run

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

Disconnect-VBRServer | out-null

connect-vbrserver -server localhost

$JobsOutput = @()

Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq "Backup"})


$LastSession = $JobObject.FindLastSession()

$ChangeRate = ($LastSession.Info.Progress.TransferedSize/$LastSession.Info.Progress.TotalUsedSize)*100

$JobOutput = New-Object -TypeName PSObject

$JobOutput | Add-Member -Name "Jobname" -MemberType Noteproperty -Value $JobObject.Name

$JobOutput | Add-Member -Name "Endtime" -MemberType Noteproperty -Value $LastSession.endtime

$JobOutput | Add-Member -Name "TotalUsedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TotalUsedSize

$JobOutput | Add-Member -Name "ReadSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.ReadSize

$JobOutput | Add-Member -Name "TransferedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TransferedSize

$JobOutput | Add-Member -Name "ChangeRate" -MemberType Noteproperty -Value $ChangeRate

$JobsOutput += $JobOutput


$JobsOutput | Out-GridView

Disconnect-VBRServer | out-null

However one result is not a fair estimate of rate of change , and I don’t have a Veeam One license so I decided to Average Stuff

You can run on One VM or all the VM’s in a Backup Job

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

connect-vbrserver -server localhost

#Query to get all jobs in the time period in hours that have processed data (Data ne 0 ) and have completed

$vbrtasksessions = (Get-VBRBackupSession |

Where-Object {($_.EndTime -ge (Get-Date).addhours(-168) -or $_.CreationTime -ge (Get-Date).AddHours(-168) -or $_.State -eq "Working")}) | Get-VBRTaskSession | Where-Object {$_.Status -notmatch "Idle|InProgress|Pending|Fail"-and $_.Info.Progress.TotalSize -ne "0"}

#Get Backup Job and VM

#$getOne = $vbrtasksessions | ? {$_.JobName -eq "%Veeam Backup or Backup Copy Name%" -and $_.Name -eq "%Name of Server%"}

#Or Get Whole Backup Job and average between all the machines

#$getOne = $vbrtasksessions | ? {$_.JobName -eq "%Veeam Backup or Backup Copy Name%"}

#Cannot Get Total usedSize in Backup

Echo ListofAllFullSizesInBytes $getOne.Info.Progress.TotalSize

#Echo AverageTotalFullBackupSizeInGB $([Math]::Round([Decimal]($getOne.Info.Progress.TotalSize | Measure-Object -Average).Average/1GB, 2))

Echo ListofIntcrementalSizeinBytess $getOne.Info.Progress.TransferedSize

#Echo AverageIntSizeinGB $([Math]::Round([Decimal]($getOne.Info.Progress.TransferedSize | Measure-Object -Average).Average/1GB, 2))

Echo RateofChangein% ((($getOne.Info.Progress.TransferedSize | Measure-Object -Average).Average/($getOne.Info.Progress.TotalSize | Measure-Object -Average).Average)*100)

Disconnect-VBRServer | out-null
GD Star Rating
GD Star Rating

Login to Azure Active Directory. Locate Usage & insights , under Monitoring

Select “Users registerd for Multi-Factor Authentication”



Can also be done in powershell :

Monitoring with PowerShell: Monitoring the used MFA type for O365/Azure.

GD Star Rating
GD Star Rating

I have been using this plugin to

highlight some of my programming. I write a bit in Powershell however this is not a supported markup. This is what to add to your functions file of your theme to add another library

/** pastcode plugin */
add_filter( 'pastacode_langs', '_pastacode_langs' );
function _pastacode_langs( $langs ) {
	$langs['powershell'] = 'Powershell';
	return $langs;

add_filter( 'pastacode_tinymcevars', '_pastacode_tinymcevars' );
function _pastacode_tinymcevars( $pvars ) {
			'libs'      => array('powershell'),
			'mode'      => 'application/x-powershell',

	return $pvars;

add_action('wp_enqueue_scripts', 'mytheme_scripts');

function mytheme_scripts() {
  wp_dequeue_script( 'prismjs' );
  wp_deregister_script( 'prismjs' );
  wp_enqueue_script( 'prismjs',  get_template_directory_uri().'/js/prism.js', false,PASTACODE_VERSION, true );


You will also need to create a js folder and upload the new .js library from and prism.js

GD Star Rating
GD Star Rating

For auditing purposes you will need to report on the updates install on a server and the install status. 

Below is a  powershell script that does just that


[email protected]('Unk','Installation','Uninstallation','Other')
[email protected]('Unk','In Progress','Succeeded','Succeeded With Errors','Failed','Aborted')

$updateSession=New-Object -ComObject Microsoft.Update.Session
$updateSearcher.QueryHistory(0, $historyCount) | 
    Select-Object Date,
                Title |
    Format-Table -AutoSize
GD Star Rating
GD Star Rating