Passed AZ-303
It is official! after passing AZ-303 today, I am now a Microsoft Certified Azure Solutions Architect Expert.
Hyper-V Nested VM
To allow your VM to run Hyper-V role, you need to expose the virtualization extension to the Hyper-V host by running the following PowerShell command:
> Set-VMProcessor -VMname MyVM -ExposeVirtualizationExtensions $true
> Set-VMProcessor -VMname MyVM -ExposeVirtualizationExtensions $true
PowerShell and Excel
I wrote a PowerShell script to start MS Excel process and manipulate an Excel file. This PS works perfectly fine when it is executed interactively by a user account. However when using Windows task scheduler, it throws the following errors:
Microsoft Excel cannot access the file
There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
In turns out, I need to create a directory named: Desktop
In the following locations:
64-Bit OS
C:\Windows\SysWOW64\config\systemprofile\Desktop
32-Bit OS
C:\Windows\System32\config\systemprofile\Desktop
Microsoft Excel cannot access the file
There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
In turns out, I need to create a directory named: Desktop
In the following locations:
64-Bit OS
C:\Windows\SysWOW64\config\systemprofile\Desktop
32-Bit OS
C:\Windows\System32\config\systemprofile\Desktop
Fix Corrupted Windows 10 File(s)
Recently, I had issue with my VM which runs Windows 10 for my daily ops work. The issue was, the hosting machine kept crashing due to unknown issue, thus ungracefully shutting down my Windows 10 VM.
One time, second time, third time were fine. Finally, one day, I wasn't able to open any ZIP file. It looked like the OS lost its association with the file type .ZIP. I went to the default file type program and could not find .zip file type. I then checked my other healthy Windows 10 machine and clearly there is no .zip file type association either.
To fix this I ran:
> sfc /scannow
When the scan was completed, I checked the log file, it had:
Could not reproject corrupted file \??\C:\WINDOWS\System32\\zipfldr.dll; source file in store is also corrupted
What I did next:
> DISM.exe /Online /Cleanup-image /Restorehealth
Then
> sfc /scannow
and I can open ZIP files again!! :)
One time, second time, third time were fine. Finally, one day, I wasn't able to open any ZIP file. It looked like the OS lost its association with the file type .ZIP. I went to the default file type program and could not find .zip file type. I then checked my other healthy Windows 10 machine and clearly there is no .zip file type association either.
To fix this I ran:
> sfc /scannow
When the scan was completed, I checked the log file, it had:
Could not reproject corrupted file \??\C:\WINDOWS\System32\\zipfldr.dll; source file in store is also corrupted
What I did next:
> DISM.exe /Online /Cleanup-image /Restorehealth
Then
> sfc /scannow
and I can open ZIP files again!! :)
Cleaning Up CSC Folders
C:\Windows\CSC folder is the offline files folder. It has special permissions. Without the correct permission, you won't be able to delete anything in it
To delete the content of C:\Windows\CSC, you need to modify its permissions
> cd c:\Windows
> takeown /f CSC /r /a /d y
> icacls CSC /grant Administrators:F
Then you can navigate to the folder and start deleting files
To delete the content of C:\Windows\CSC, you need to modify its permissions
> cd c:\Windows
> takeown /f CSC /r /a /d y
> icacls CSC /grant Administrators:F
Then you can navigate to the folder and start deleting files
Windows 2016 Core Domain Controllers
Upgrading my Domain Controllers from 2012 R2 to 2016. I have decided to run the servers without Desktop Experience to save resources.
Once installed, run the "sconfig" utility from the CMD to setup the server name, IP address, DNS and gateway, then reboot
To add AD Domain Services feature:
Add-WindowsFeature AD-Domain-Services
To install AD Forest::
Install-ADDSForest -CreateDnsDelegation:$false
-DatabasePath C:\Windows\NTDS
-DomainMode WinThreshold
-DomainName domain.tld
-DomainNetbiosName NETBIOSDOMAIN
-ForestMode WinThreshold
-InstallDns:$true
-LogPath C:\Windows\NTDS
-NoRebootOnCompletion:$true
-SysvolPath C:\Windows\SYSVOL
-Force:$true
ForestMode = WinThreshold = for Windows 2016
To add AD Domain Controller to the existing domain:
Install-ADDSDomainController -CreateDnsDelegation:$false
-DatabasePath C:\Windows\NTDS
-DomainName domain.tld
-InstallDns:$true
-LogPath C:\Windows\NTDS
-NoGlobalCatalog:$false
-SysvolPath C:\Windows\SYSVOL
-NoRebootOnCompletion:$true
-Force:$true
-Credential (Get-Credential)
Once installed, run the "sconfig" utility from the CMD to setup the server name, IP address, DNS and gateway, then reboot
To add AD Domain Services feature:
Add-WindowsFeature AD-Domain-Services
To install AD Forest::
Install-ADDSForest -CreateDnsDelegation:$false
-DatabasePath C:\Windows\NTDS
-DomainMode WinThreshold
-DomainName domain.tld
-DomainNetbiosName NETBIOSDOMAIN
-ForestMode WinThreshold
-InstallDns:$true
-LogPath C:\Windows\NTDS
-NoRebootOnCompletion:$true
-SysvolPath C:\Windows\SYSVOL
-Force:$true
ForestMode = WinThreshold = for Windows 2016
To add AD Domain Controller to the existing domain:
Install-ADDSDomainController -CreateDnsDelegation:$false
-DatabasePath C:\Windows\NTDS
-DomainName domain.tld
-InstallDns:$true
-LogPath C:\Windows\NTDS
-NoGlobalCatalog:$false
-SysvolPath C:\Windows\SYSVOL
-NoRebootOnCompletion:$true
-Force:$true
-Credential (Get-Credential)
Proxy Enforcer
I developed this little utility while doing proxy migration project. This utility helps me to enforce the Windows proxy settings to IE.
You can add Proxy by clicking the "Add Proxy" button, which gives you the same configuration like Windows
You can add Proxy by clicking the "Add Proxy" button, which gives you the same configuration like Windows
Once your proxy setting is added to the list, highlight the proxy and click "Select Proxy" to enforce the selected proxy to your IE. The program will run on the TaskBar.
Windows 2012 R2 - File Backup
I need to backup my files running on Windows 2012 R2 to external drive. I also need this to be done in a regular basis and send me an email after the job done with the report.
First, I create a batch file, called backup.bat, with the content
@echo off
robocopy H:\Home V:\Home /MIR /R:1 /W:1 /LOG:V:\Home.txt
robocopy K:\Documents V:\Documents /MIR /R:1 /W:1 /LOG:V:\Documents.txt
copy /b V:\Documents.txt +V:\Home.txt V:\Backup.txt
The last line is joining the 2 log files into a single file, backup.txt
Schedule this daily with the Windows Scheduler, having an actions:
Start a Program: cmd.exe
Add arguments: /c D:\scripts\backup.bat
That bit is done for backup job.
Now, the email bit. I create a powershell script, called email.ps1, with the content:
First, I create a batch file, called backup.bat, with the content
@echo off
robocopy H:\Home V:\Home /MIR /R:1 /W:1 /LOG:V:\Home.txt
robocopy K:\Documents V:\Documents /MIR /R:1 /W:1 /LOG:V:\Documents.txt
copy /b V:\Documents.txt +V:\Home.txt V:\Backup.txt
The last line is joining the 2 log files into a single file, backup.txt
Schedule this daily with the Windows Scheduler, having an actions:
Start a Program: cmd.exe
Add arguments: /c D:\scripts\backup.bat
That bit is done for backup job.
Now, the email bit. I create a powershell script, called email.ps1, with the content:
function sendMail{
Write-Host "Sending Email"
#SMTP server name
$smtpServer = "smtprelay.domain.local"
#Creating a Mail object
$msg = new-object Net.Mail.MailMessage
#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
#Email structure
$msg.From = "backup@mydomain.id.au"
$msg.ReplyTo = "backup@mydomain.id.au"
$msg.To.Add("me@mydomain.id.au")
$msg.subject = "Backup Email - Daily"
$msg.body = "Backup Email - Daily"
$attachment = New-Object System.Net.Mail.Attachment("V:\Backup.txt", 'text/plain')
$msg.Attachments.Add($attachment)
#Sending email
$smtp.Send($msg)
}
#Calling function
sendMail
The email powershell script attach the backup.txt file and send it away
On the same schedule job created earlier, add a second action:
Start a Program: powershell
Add arguments: D:\scripts\email.ps1
Done. Second action will be executed after the 1st action is running and it will grab the log and attach it to the email.
.NET Executing Assembly Location
During coding, if you want to reference another file, such as configuration file, text file or XML file that is located on the same location where your binary/library is you can use the following:''
string location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Have fun coding :)
string location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Have fun coding :)
Hello Windows 10!
Today, I installed Windows 10 Enterprise x64 Edition, and it looks great!!
Look at that, how slick does it look? I like it!
More to come on this blog about Windows 10.. stay tune.
SCCM 2007 R2 Software Updates Diagram
My SCCM 2007 R2 Software Update relationship diagram.
Search Folder
This contains all the updates metadata that meets the criteria, e.g. superseded: no, expired:no, etc
Update List
This is the list of updates that are selected from search folder. I use this update list per month basis, e.g. Jan 2015, Feb 2015. This way, a compliance report can be run agains a specific update list.
Deployment Packages
This is the deployment package that gets deploy to the Distribution Point. I use the same deployment package for a specific product, for example I have "Windows Server 2012 R2" deployment package for all updates of Windows Server 2012 R2, respectively of their month.
Deployment Management
This is the deployment task that is created for a specific collection.
Collections
A collection of computers that is targeted for software updates
What to do every month to patch machines?
- Go to the search folder, select all the updates for this month for a specific product
- Right click and select Download Software Updates, target the deployment packages for that product. Don't forget to update Distribution Point
- Right click and select Update List, create a new Update list for this month.
- From the newly created Update List, select all the updates and click-and-drag them to the Deployment Task for a specific collection that you want to install the updates on
- Check the software available and installation deadline for that Deployment task
Subscribe to:
Posts (Atom)













