Backup / Restore startmenu design (Layout)

If you want to backup your startmenu layout you can export using:

1
export-startlayout –path C:\layout.xml

BUT,You can import a Start Menu layout using Group Policy Editor (gpedit). After importing the layout it will be fixed, that is you will not be able to change that layout by moving the tiles around.

or better yet copy it as below.

 

backup:

Files are saved in the location of the script.

1
2
Reg export ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount") ("backup_startmenu.reg") /y
Copy-Item ("$env:LOCALAPPDATA\Microsoft\Windows\Shell\DefaultLayouts.xml") -Destination ("backup_startmenu.xml")

 

restore:

1
2
3
Reg delete ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount") /f
Reg import ("backup_startmenu.reg")
Copy-Item ("backup_startmenu.xml") -Destination ("$env:LOCALAPPDATA\Microsoft\Windows\Shell\DefaultLayouts.xml")

 

All in one menu and options (save as anything.ps1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#------------------------------------------------------------------------------
# AUTHOR(s):
# Kyle Wadman
# 12/2019
# -----------------------------------------------------------------------------
CLS
$Loop = $true
While ($Loop)
{
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Start | PowerShell Script menu
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CLS
write-host
write-host +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
write-host "Startmenu backup/restore | -V1.0 Windows 10"
write-host +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
write-host
write-host -ForegroundColor yellow "Your can use the export-startlayout command to complete this task but on importing back into the system,"
write-host -ForegroundColor yellow "your startmenu will be fixed to the exported design. This method doesn't restricted changes after."
write-host
write-host 'PLEASE SELECT AN OPTION '
write-host -ForegroundColor gray '------------------------------------------------'
write-host -ForegroundColor green 'B) BACKUP'
write-host -ForegroundColor gray '------------------------------------------------'
write-host -ForegroundColor cyan 'R) RESTORE'
write-host -ForegroundColor gray '------------------------------------------------'
write-host -ForegroundColor yellow 'X) Exit'
write-host

$opt = Read-Host "Select an option "
write-host $opt
switch ($opt)
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# End of | PowerShell Script menu
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

{
b { #BACKUP SCRIPT
CLS
write-host "Exporting Reg >"; Reg export ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount") ("backup_startmenu.reg") /y
write-host "Collect XML >"; try{Copy-Item ("$env:LOCALAPPDATA\Microsoft\Windows\Shell\DefaultLayouts.xml") -Destination ("backup_startmenu.xml")} #-ErrorAction SilentyContinue
catch{write-host "Failed to find XML"; pause; break}; write-host "The operation completed successfully."
write-host -BackgroundColor yellow -ForegroundColor red " All Done "
pause
}

r { #RESTORE SCRIPT
CLS
write-host "Clean reg >"; Reg delete ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount") /f
write-host "Import reg >"; Reg import ("backup_startmenu.reg")
write-host "Place XML >"; try{Copy-Item ("backup_startmenu.xml") -Destination ("$env:LOCALAPPDATA\Microsoft\Windows\Shell\DefaultLayouts.xml")}
catch{write-host "Failed to Place XML"; pause; break}; write-host "The operation completed successfully."

write-host -BackgroundColor yellow -ForegroundColor red " You now need to logout and back in to see the results. "
pause
}

x{#BYE
CLS
write-host "Goodbye, It was nice to see you today."
exit
}

}
}

 

I did find someone has built this process into an application here.  For coded requirements, you can thank me later.

Maybe for personal backups, check out the software version.

Print Friendly, PDF & Email

Powershell Check Registry

The below code looks for a registry ‘String Name’ in a ‘current user’ registry path (Key).

  • HKCU (Current User)
  • HKLM (Local Machine)

If the StringName doesn’t exist, it runs the code in the ‘processing block’. It then writes the exact registry item it looked up in the first place.

IF/When the script is run again it will this time PASS the test and the code block “NO ACTION” will be executed.

 

This function can be added once to the top of your script, then called for multi use later.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Function CheckRegFlag($Func_State,$Func_key,$Func_StringName,$Func_StringValue){
switch($Func_State)
{
start {
$TestPath = (Get-ItemProperty $Func_key) -ne $null
IF ($TestPath -eq "") {
New-Item -Path $Func_key -force | Out-Null
}

$TestValue = (Get-ItemProperty $Func_key).$Func_StringName -ne $null
IF ($TestValue -eq "")
{$Func_WorkNeeded = "Y"; write-host "action needed"}
ELSE
{$Func_WorkNeeded = "N"; write-host "already run"}
}

stop { New-ItemProperty -Path $Func_key -Name $Func_StringName -Value $Func_StringValue |Out-Null; write-host "Saving Flag"}
Default { write-host "No State given"; pause; break}
}
return $Func_WorkNeeded
}

This next bit can be used time and time again to test and complete actions (adding your code to the DO All Commands here)

1
2
3
4
5
6
7
8
9
10
#REG values to check/write
$var_key = ("HKCU:\SOFTWARE\TestKey") #LOCATION OF STRING-NAME IN REG
$var_StringName = ("TestName") #THIS IS WHAT IS CHECKED FOR, NOT THE VALUE.
$var_StringValue = ("TestValue") #THIS IS FOR NOTES

$ActionMe = CheckRegFlag "start" "$var_key" "$var_StringName"
switch($ActionMe){
Y{ write-host "Do all commands here"
CheckRegFlag "stop" "$var_key" "$var_StringName" "$var_StringValue"}
}
Print Friendly, PDF & Email

WMindows 10 Profile backup

It’s been a while and this is shortly explained but the following script is designed to backup a users profile in windows 10 (1903) but should work on all Windows 10.

Line 149: $var_backupRoot needs to be updated to a backup ROOT location.

Download File

 

 

 

 

 

 

 

 

Print Friendly, PDF & Email

Windows 10 “Just a Moment”

So I started my Windows 10 Golden image on 1607.  I upgraded to 1703 and then after deployment to the machine it gets stuck on “just a moment”.

Add the following to your unattended and all will be right with the world once more.

<OOBE>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Work</NetworkLocation>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
</OOBE>

For more detail please see source

Print Friendly, PDF & Email

FOG V 1.3.0 on CentOS 7 Full Install Guide

FOG now live, Manual BETA!

Last updated 04/01/2017

 

Welcome to another FOG guide.  This time, lets install FOG

Base OS = CentOS 7 x64 (DVD Ver)
FOG = 1.3.0

Please note this guide follows the best practice for CentOS7 installation issued by the FOG Team.
I’ve just spent the extra time to hold your hand the hole way.

I will redo this guide into the FOG Wiki when I get time.

Anyway, Lets get on…

Step One – Install CentOS

This is basic but I will list all to make sure we are setting up the same.

1. Download CentOS7 (x64) (Direct Link) & burn to DVD.

http://mirror.ox.ac.uk/sites/mirror.centos.org/7/isos/x86_64/CentOS-7-x86_64-DVD-1511.iso

2. At installation of CentOS, select the following options:

-Select Language (UK)
-Select complete disk for installation location (unless you want something fancy)
-Setup Static IP (rename port to eth0 if not defaulted already) & Enable NIC
-Select KDE desktop from packages (Why not add some GUI, not required)
-NEXT / CONTINUE
-Set ROOT password (no need to add more accounts)
-Wait for install to complete, Remove media and reboot.

 

Step Two – Configure OS

1. Forget the GUI, Connect to the new server via SSH and lets begin.

2. Lets disable SELINUX & the firewall.

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld

3. Lets now update the OS.
(This may take a while to complete, and you might have to accept some overwrites)

yum -y update && reboot

INFORMATION:

OK, so now we have CentOS7x64  installed, patched, rebooted and ready to go.

 

 

Step Three– Adding Applications

1. A few items that FOG / we need to complete the mission.

yum -y install htmldoc ttf2pt1 t1utils fltk subversion wget mariadb-server mariadb

INFORMATION:

CentOS doesn’t use MySQL as std.  Instead we will be using MaridaDB.
This is mysql just renamed.

2. Now lets turn MaridDB on and keep it on.

systemctl start mariadb
systemctl enable mariadb

3. GOOD !.  Now lets make MaridDB secure.

mysql_secure_installation

4. Pick the following options

-current pwd = BLANK
-Set Root = Y (then add new pwd for SQL)
-Remove anon = Y
-Disallow root remote = N (you can pick this one)
-Remove test DB = Y
-Reload = Y

 

Step Four– Getting FOG

1. Lets 1st get to a DIR we all know (root home)

cd ~

2. Now Lets download FOG and put it into a DIR

ALERT:

Please note version 1.3.0 is in beta

svn co https://svn.code.sf.net/p/freeghost/code/trunk FogDownload

 

Step Five– Install FOG

INFORMATION:

Almost there, Just got to install Fog now:

WARNING:

(now is a good time to snapshot if in VM)

1. type below in terminal:

cd FogDownload/bin

2. type below in terminal:

./installfog.sh

3. Setup as I have below

-Choice = 1
-Type = <press return>
-IP (is shown) = <press return>
-DHCP Router = y  --(Enter IP of your DHCP server)
-DNS for DHCP = y --(Enter DNS Server)
-Change Default eth0 = n
-FOG as DHCP = n
-Language packs = n
-donate = n --(Sorry, not now)
-Continue = y

INFORMATION:

Fog will start to install before it stops to ask about SQL.

##What is the storage location for your images directory? (/images)

4. A question is asked of you.
did you leave the mysql password blank during install?

answer = n
input password & continue.

 

!!ALERT !!

! You must read the next bit carefully !

=============================

The script now tell you do go do something and then press continue when it’s been done.  

Don’t be the one to just press continue!

 

5.  When the script stops on “Press [Enter] “, open the following URL on another machine in the browser of your choice. (Lets just use IE 11 as a Standard)


http://<fog server ip>/fog/management

6. Click the button “install“.

7. Go back to the install script and now “Press [Enter] “.

INFORMATION:

Fog will continue to install & finish.

 

Step Six– Add DHCP Settings

1. Open DHCP

2.

https://wiki.fogproject.org/wiki/index.php/FOGUserGuide#Windows_Server_DHCP

**********************************

! Installation Complete !

**********************************

 

-FOG Login

1. Lets take a look at fog !!

http://<fog server ip>/fog
username = fog
password = password

 

 

 

 

-Troubleshooting

You can control services as in examples below:


systemctl start <service>

systemctl stop <service>

systemctl status <service>

 

more e.g.

systemctl status httpd

systemctl status mariadb

Print Friendly, PDF & Email

XenServer – Change DNS Server IP

If you want to change the config of the nameservers in xenserver you can just edit this file.


1) login to xenserver via SSH or console

2) Type "nano /etc/resolv.conf"

3) Make changes

4) Press Crtl+W to write (Y to confirm)

5) Press Ctrl+X to exit.

Print Friendly, PDF & Email

VBS Clean Printer list

If your looking to delete all the printers via script this is your code.
You can change the SELECT to pick certain printers.

This .vbs can be deployed using GPO as a user login script.


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where ServerName = '\\\\servername'",,48)
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next

All Printers


("SELECT * FROM Win32_Printer")

All printers where they are offline


("SELECT * FROM Win32_Printer WHERE ExtendedPrinterStatus = 2")

 

 

For more select statements please compile them using the information below.

http://msdn.microsoft.com/en-gb/library/windows/desktop/aa394363(v=vs.85).aspx

http://www.scriptinternals.com/new/us/support/Internal/WMI_Win32_Printer.htm

or search for “WMI Win32_Printer class”

Another useful tool is WMI Code Creator.
This will show you the values of current WMI records and build your select.

Print Friendly, PDF & Email

Specify directory with spaces in /etc/fstab

If you want to add a filesystem to mount in /etc/fstab you need to use the octal ASCII value which is \040. In my case I have created a separate filesystem for VMware virtual machines:

/dev/mapper/vmwarefs  /var/lib/vmware/Virtual\040Machines ext3 defaults 1 1

If you have any other special characters which are causing problems you can check with

man ascii

for the value you need to specify.

Print Friendly, PDF & Email

Windows 7, kick logged on users like XP did

This little program allows any user of the local admin group to log off a user who has locked their machine, just like in windows XP without using fast user switching. It basically takes seconds to install and when a user locks their machine, they get the message stating that user x has locked this machine … “This computer is locked. Only the logged on user can unlock the computer” and to unlock it you need to press control, alt, del and log in with the users details who have locked the machine.

 

Download Application & Code

Source site: View forum post

 

Print Friendly, PDF & Email

mount samba share on MAC desktop

Locate apple script on your system under utilities.  Create a new document and do one of the two below actions.

 

tell application "finder"
map volume "smb://servername/servershare"
end tell

OR with username and password

tell application "Finder"
mount volume "smb://WORKGROUP;username:password@servername/servershare"
end tell

Save the file, I change it from a script to an application so I can still edit it, but i can just double click it to use it.

If you want this to work automatically, add the script to the user account startup options found in the account settings in settings.

 

Other apple commands, good read 😉

http://www.tuaw.com/2007/12/29/applescript-finder-commands/

Print Friendly, PDF & Email