Skip to content

Instantly share code, notes, and snippets.

View vmsilvamolina's full-sized avatar
🖖
One day or day one. You decide...

Victor Silva vmsilvamolina

🖖
One day or day one. You decide...
View GitHub Profile
# Define your info into variables
$hostpoolName = "General"
$resourceGroup = "AVD-RG"
$hostpool = Get-AzWvdHostPool | Where-Object { $_.Name -eq $hostpoolName }
$sessionHosts = Get-AzWvdSessionHost -ResourceGroupName $resourceGroup -HostPoolName $hostpool.name
$existingHostName = $sessionHosts[-1].Id.Split("/")[-1]
$adDomain = $sessionHosts[-1].Id.Split("/")[-1].split(".", 2)[1]
$currentVmInfo = Get-AzVM -Name $existingHostName.Split(".")[0]
$imageReference = ($currentVmInfo.storageprofile.ImageReference).id
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@vmsilvamolina
vmsilvamolina / Form.ps1
Created October 3, 2019 18:09
Ejemplo de formulario con actualización de texto
#Cargo los Assemblies (necesario para definir el form)
[void][reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[void][reflection.assembly]::loadwithpartialname("System.Drawing")
#Creo el objeto Form
$Form = New-Object System.Windows.Forms.Form
#Defino el tamaño del formulario
$Form.Size = New-Object Drawing.Size(400,200)
#Defino la posición inicial
$Form.StartPosition = "CenterScreen"
#Defino el titulo del formulario
---
layout: null
permalink: /entries.json
sitemap: false
---
{
"title": "{{ site.title}}",
"url": "{{ site.url }}",
"posts": [
$files = Get-Content C:\users\vmsil\Desktop\Files.txt
[System.Collections.ArrayList]$hashDB = @()
foreach ($file in $files) {
$hash = (Get-FileHash -Path $file -Algorithm MD5).Hash
$elemento = New-Object PSObject
$elemento | Add-Member -type NoteProperty -Name 'Hash' -Value $hash
$elemento | Add-Member -type NoteProperty -Name 'FilePath' -Value $file
$hashDB.Add($elemento) | Out-Null
}
Import-Module Hyper-V
$ExchangeServer = "afasrv09.afinidad.interno"
$VmReplication = Get-VMReplication -ComputerName afahv1,afahv2,surasrvhv01,surasrvhv02 `
| Select-Object @{Name="Maquinas Virtuales";Expression={($_.Name)}},
@{Name="Estado de la replica";Expression={($_.State)}},
@{Name="Estado";Expression={($_.Health)}},
@{Name="Host";Expression={($_.PrimaryServer)}} | ConvertTo-HTML -fragment
$Body = @"
<!doctype html>
<html lang="es">
@vmsilvamolina
vmsilvamolina / CreateVMwithARM.ps1
Created July 8, 2017 16:51
Cómo crear una VM en Azure utilizando PowerShell y ARM
#region Virtual Network
## Creamos la subred:
$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name SubnetTest -AddressPrefix 192.168.1.0/24
## Creamos la red virtual con la subred y el resource group anterior:
$vnet = New-AzureRmVirtualNetwork -ResourceGroupName ResourceGroupTest `
-Location "South Central US" `
-Name VnetTest `
-AddressPrefix 192.168.0.0/16 `
@vmsilvamolina
vmsilvamolina / WindowsAutoStart.ps1
Last active April 18, 2020 19:03
WindowsAutoStart is a script to run when reinstall my personal Notebook.
### Script to use when reinstall Windows (personal) ###
##### Version history:
# 0.1 - 23/03/2017 - Add Chocolatey and basic software
# 0.2 - 17/10/2017 - Add new software
# 0.3 - 13/04/2018 - Remove visio and spotify
#####
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] “Administrator”)) {
Write-Host “You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!”
@vmsilvamolina
vmsilvamolina / IIS_ARR_Web.ps1
Created December 23, 2016 03:51
IIS ARR WEB
#URL y nombre del servidor
$PsPath = 'MACHINE/WEBROOT/APPHOST'
$URL = "sip.dominio.com"
$Server = "PoolSfB.dominio.local"
#Farm nuevo (usando el nombre de la URL)
Add-WebConfigurationProperty -pspath $PsPath -filter "webFarms" -name "." -value @{name="$($URL)"}
Add-WebConfigurationProperty -pspath $PsPath -filter "webFarms/webFarm[@name='$($URL)']" -name "." -value @{address="$($Server)"}
#Puertos
Set-WebConfigurationProperty -pspath $PsPath -filter "webFarms/webFarm[@name='$($URL)']/server[@address='$($Server)']/applicationRequestRouting" -name "httpPort" -value 8081
Set-WebConfigurationProperty -pspath $PsPath -filter "webFarms/webFarm[@name='$($URL)']/server[@address='$($Server)']/applicationRequestRouting" -name "httpsPort" -value 8443
@vmsilvamolina
vmsilvamolina / IIS_ARR_OWA.ps1
Created December 23, 2016 03:50
IIS ARR OWA
#URL y nombre del servidor
$PsPath = 'MACHINE/WEBROOT/APPHOST'
$URL = "office.dominio.com"
$Server = "OWA.dominio.local"
#Farm nuevo (usando el nombre de la URL)
Add-WebConfigurationProperty -pspath $PsPath -filter "webFarms" -name "." -value @{name="$($URL)"}
Add-WebConfigurationProperty -pspath $PsPath -filter "webFarms/webFarm[@name='$($URL)']" -name "." -value @{address="$($Server)"}
#Cache
Set-WebConfigurationProperty -pspath $PsPath -filter "webFarms/webFarm[@name='$($URL)']/applicationRequestRouting/protocol/cache" -name "enabled" -value "False"
#Timeout