Skip to content

Instantly share code, notes, and snippets.

View PrzemyslawKlys's full-sized avatar
🍉
Dreaming about great things! A bit bored...

Przemysław Kłys PrzemyslawKlys

🍉
Dreaming about great things! A bit bored...
View GitHub Profile
#Install-Module ImportExcel
Import-Module ImportExcel
$file = Import-Excel -Path "Book1.xlsx"
$test = @()
foreach ($l in $file) {
$test += "$($l.Name) $($l.Surname)"
}
$test | Export-Excel -Path "Book-Exported.xlsx"
function Test-Array {
param (
[string[]] $other = @(),
[bool[]] $thisValue = @(),
[bool[]] $Bold = @(),
[bool[]] $Italic = @()
)
$thisValue.GetType()
$bold.GetType()
foreach ($value in $thisValue) {
<#
.SYNOPSIS
Create a new desktop wallpaper from various sources and optionally overlay some text.
.DESCRIPTION
The script can be run manually, at logon or even as a scheduled task to update the wallpaper regularly
Wallpaper sources include:
- A solid colour
@PrzemyslawKlys
PrzemyslawKlys / gist:46bbb9e1acb24fe09b530d071f92cbe6
Last active November 5, 2018 08:24
Merge-Array - Adding field
$Array1 = @()
$Element1 = [PSCustomObject] @{ Name = 'Company1'; Count = 259 }
$Element2 = [PSCustomObject] @{ Name = 'Company2'; Count = 300 }
$Array2 = @()
$Element3 = [PSCustomObject] @{ Name = 'Company1'; Count = 25 }
$Element4 = [PSCustomObject] @{ Name = 'Company2'; Count = 100 }
$lists = Get-PnPList -Includes RootFolder.ServerRelativeUrl, IsCatalog, IsSiteAssetsLibrary
$Rewritten = foreach ($list in $lists) {
[PSCustomObject] @{
Id = $List.Id
Title = $list.Title
Url = $list.RootFolder.ServerRelativeUrl
IsCatalog = $List.IsCatalog
IsSiteAssetsLibrary = $List.IsSiteAssetsLibrary
}
}
@PrzemyslawKlys
PrzemyslawKlys / beginprocessend.ps1
Last active May 1, 2019 07:07
Testing break on Begin/process/End
Clear-Host
Function Limit-BlockUsageOne {
[CmdletBinding()]
Param (
$Stop = 1
)
Begin {
if ($Stop -eq 2) {
break
@PrzemyslawKlys
PrzemyslawKlys / Example.ps1
Created May 1, 2019 21:34
Small example of skiping $array+=
# Surname list from a web site
$uri = "https://names.mongabay.com/most_common_surnames.htm"
$data = Invoke-WebRequest $uri
$table_surname = $data.ParsedHtml.getElementsByTagName("table") | Select -first 1
[array]$table_surname = $table_surname | select -ExpandProperty innertext
$table_surname = $table_surname.Replace("SurnameApproximate", "").replace("Number%", "").replace("FrequencyRank", "")
$table_surname = $table_surname -split "`n"
[regex]$filter = '[^a-zA-Z]'
$surname_list = $table_surname -replace $filter
@PrzemyslawKlys
PrzemyslawKlys / PowerShellProfile.ps1
Last active September 7, 2019 21:00
PowerShell Profile
Clear-Host
Write-Color "Windows PowerShell"
Write-Color "Copyright (C) Microsoft Corporation. All rights reserved." -LinesAfter 1
<# Alternatively if you don't have Write-Color
Clear-Host
Write-Host "Windows PowerShell"
Write-Host "Copyright (C) Microsoft Corporation. All rights reserved."
Write-Host
#>
function Get-Sid {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[System.String]
$Account,
[Parameter(Mandatory = $false, Position = 1)]
[System.String]
$Domain = $null
function Get-Sid {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0)]
[System.String]
$Account,
[Parameter(Mandatory = $false, Position = 1)]
[System.String]
$Domain = $null