Jump to content

MartinByard

Members
  • Posts

    149
  • Joined

  • Last visited

Everything posted by MartinByard

  1. We get rid of (most of) the pre-provisioned apps running the below script, during our SCCM Task sequence, before it does the reboot to install the SCCM client and setup windows. It can be faily easily altered to either leave more apps (if they're needed) or be harsher and remove more apps by editing the whitelist in each section. # Functions function Write-LogEntry { param( [parameter(Mandatory=$true, HelpMessage="Value added to the RemovedApps.log file.")] [ValidateNotNullOrEmpty()] [string]$Value, [parameter(Mandatory=$false, HelpMessage="Name of the log file that the entry will written to.")] [ValidateNotNullOrEmpty()] [string]$FileName = "RemovedApps.log" ) # Determine log file location $LogFilePath = Join-Path -Path $env:windir -ChildPath "Temp\$($FileName)" # Add value to log file try { Out-File -InputObject $Value -Append -NoClobber -Encoding Default -FilePath $LogFilePath -ErrorAction Stop } catch [system.Exception] { Write-Warning -Message "Unable to append log entry to RemovedApps.log file" } } Start-transcript -Path C:\Windows\Remove_Apps.txt -Force # Get a list of all apps Write-LogEntry -Value "Starting built-in AppxPackage, AppxProvisioningPackage and Feature on Demand V2 removal process" $AppArrayList = Get-AppxPackage -PackageTypeFilter Bundle -AllUsers | Select-Object -Property Name, PackageFullName | Sort-Object -Property Name # White list of appx packages to keep installed $WhiteListedApps = New-Object -TypeName System.Collections.ArrayList $WhiteListedApps.AddRange(@( "Microsoft.DesktopAppInstaller", "Microsoft.MSPaint", "Microsoft.MicrosoftStickyNotes", "Microsoft.WindowsCalculator", "Microsoft.WindowsSoundRecorder", "Microsoft.WindowsStore" "Microsoft.Windows.Photos" )) #"Microsoft.Messaging", #"Microsoft.StorePurchaseApp", #"Microsoft.MicrosoftOfficeHub", #"Microsoft.WindowsAlarms", #"Microsoft.WindowsCommunicationsApps", # Mail, Calendar etc # Windows 10 version 1809 $WhiteListedApps.AddRange(@( "Microsoft.ScreenSketch", "Microsoft.HEIFImageExtension", "Microsoft.VP9VideoExtensions", "Microsoft.WebMediaExtensions", "Microsoft.WebpImageExtension" )) # Loop through the list of appx packages foreach ($App in $AppArrayList) { # If application name not in appx package white list, remove AppxPackage and AppxProvisioningPackage if (($App.Name -in $WhiteListedApps)) { Write-LogEntry -Value "Skipping excluded application package: $($App.Name)" } else { # Gather package names $AppPackageFullName = Get-AppxPackage -Name $App.Name | Select-Object -ExpandProperty PackageFullName -First 1 $AppProvisioningPackageName = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -like $App.Name } | Select-Object -ExpandProperty PackageName -First 1 # Attempt to remove AppxPackage if ($AppPackageFullName -ne $null) { try { Write-LogEntry -Value "Removing AppxPackage: $($AppPackageFullName)" Remove-AppxPackage -Package $AppPackageFullName -Verbose -ErrorAction Stop #| Out-Null Start-Sleep 60 } catch [system.Exception] { Write-LogEntry -Value "Removing AppxPackage '$($AppPackageFullName)' failed: $($_.Exception.Message)" } } else { Write-LogEntry -Value "Unable to locate AppxPackage: $($AppPackageFullName)" } # Attempt to remove AppxProvisioningPackage if ($AppProvisioningPackageName -ne $null) { try { Write-LogEntry -Value "Removing AppxProvisioningPackage: $($AppProvisioningPackageName)" Remove-AppxProvisionedPackage -PackageName $AppProvisioningPackageName -Online -Verbose -ErrorAction Stop #| Out-Null Start-Sleep 60 } catch [system.Exception] { Write-LogEntry -Value "Removing AppxProvisioningPackage '$($AppProvisioningPackageName)' failed: $($_.Exception.Message)" } } else { Write-LogEntry -Value "Unable to locate AppxProvisioningPackage: $($AppProvisioningPackageName)" } } } # White list of Features On Demand V2 packages Write-LogEntry -Value "Starting Features on Demand V2 removal process" $WhiteListOnDemand = "NetFX3|Tools.Graphics.DirectX|Tools.DeveloperMode.Core|Language|Browser.InternetExplorer|ContactSupport|OneCoreUAP|Media.WindowsMediaPlayer" # Get Features On Demand that should be removed try { $OSBuildNumber = Get-WmiObject -Class "Win32_OperatingSystem" | Select-Object -ExpandProperty BuildNumber # Handle cmdlet limitations for older OS builds if ($OSBuildNumber -le "16299") { $OnDemandFeatures = Get-WindowsCapability -Online -ErrorAction Stop | Where-Object { $_.Name -notmatch $WhiteListOnDemand -and $_.State -like "Installed"} | Select-Object -ExpandProperty Name } else { $OnDemandFeatures = Get-WindowsCapability -Online -LimitAccess -ErrorAction Stop | Where-Object { $_.Name -notmatch $WhiteListOnDemand -and $_.State -like "Installed"} | Select-Object -ExpandProperty Name } foreach ($Feature in $OnDemandFeatures) { try { Write-LogEntry -Value "Removing Feature on Demand V2 package: $($Feature)" # Handle cmdlet limitations for older OS builds if ($OSBuildNumber -le "16299") { Get-WindowsCapability -Online -ErrorAction Stop | Where-Object { $_.Name -like $Feature } | Remove-WindowsCapability -Online -Verbose -ErrorAction Stop #| Out-Null Start-Sleep 60 } else { Get-WindowsCapability -Online -LimitAccess -ErrorAction Stop | Where-Object { $_.Name -like $Feature } | Remove-WindowsCapability -Online -Verbose -ErrorAction Stop #| Out-Null Start-Sleep 60 } } catch [system.Exception] { Write-LogEntry -Value "Removing Feature on Demand V2 package failed: $($_.Exception.Message)" } } } catch [system.Exception] { Write-LogEntry -Value "Attempting to list Feature on Demand V2 packages failed: $($_.Exception.Message)" } # Complete Write-LogEntry -Value "Completed built-in AppxPackage, AppxProvisioningPackage and Feature on Demand V2 removal process" Stop-Transcript As for adding a user - any reason you couldn't add a simple run command line (or powershell, whatrever you fancy) step somewhere in the task sequence, to do : net.exe user /add "Admin Username" "Admin Password" /fullname:"Admin Username" /comment:"Local admin account" net.exe localgroup administrators "Admin Username" /add WMIC USERACCOUNT WHERE "Name='Admin Username'" SET PasswordExpires=FALSE
  2. Dungeons 3 is free on the epic games store this week. https://www.epicgames.com/store/en-US/product/dungeons-3/home
  3. We use these on the ones we have (only half a dozen so far, driving our digital signage). https://www.amazon.co.uk/GeeekPi-Raspberry-Adapter-40X40X10mm-Heatsinks/dp/B07X9R8V96/
  4. MS recommend that the SQL is installed on the same box, unless you're in really large environments or want to use a HA cluster.
  5. Total War : Troy is free on epic games until 2pm on the 14th, if anyone fancies it.
  6. At a guess, its wanting to add language packs, or features on demand.
  7. For the OU query, try using $obj | Add-Member NoteProperty "OU" (Get-ADComputer -Identity $Computer | Select-Object DistinguishedName).DistinguishedName For the Model query, try using $obj | Add-Member NoteProperty "Model" (Get-WmiObject Win32_ComputerSystem -ComputerName $Computer | Select-Object -Property Model).Model For the Serial number, try using $obj | Add-Member NoteProperty "SerialNumber" (Get-WmiObject Win32_BIOS -ComputerName $Computer| Select-Object -Property SerialNumber).SerialNumber For the hotfix, try using $obj | Add-Member NoteProperty "WindowsUpdates"(get-hotfix -ComputerName $Computer | Select-Object HotfixID).HotfixID that should fetch just the actual values you want and put it in the $obj array.
  8. Try this one ... I'd left some spaces in the variable names for the email bit. The only query I've got is about the bit where you query the event log to get events with the ID 6005, and what thats actually meant to do (I've commented it out in this version). Add-Type -AssemblyName System.Windows.Forms [system.Windows.Forms.Application]::EnableVisualStyles() $FormName = New-Object system.Windows.Forms.Form $FormName.ClientSize = '400,400' $FormName.text = "Form" $FormName.TopMost = $false $Label1 = New-Object system.Windows.Forms.Label $Label1.text = "Please Enter Computer Name" $Label1.AutoSize = $true $Label1.width = 25 $Label1.height = 10 $Label1.location = New-Object System.Drawing.Point(10,20) $Label1.Font = 'Microsoft Sans Serif,10' $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 374 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(10,40) $TextBox1.Font = 'Microsoft Sans Serif,10' $Button1 = New-Object system.Windows.Forms.Button $Button1.text = "Click to Find IP \ Mac Address of Computer" $Button1.width = 374 $Button1.height = 30 $Button1.location = New-Object System.Drawing.Point(10,65) $Button1.Font = 'Microsoft Sans Serif,10' $Label2 = New-Object system.Windows.Forms.Label $Label2.text = "Email Address" $Label2.AutoSize = $true $Label2.width = 25 $Label2.height = 10 $Label2.location = New-Object System.Drawing.Point(11,320) $Label2.Font = 'Microsoft Sans Serif,10' $Button2 = New-Object system.Windows.Forms.Button $Button2.text = "Send As Email" $Button2.width = 150 $Button2.height = 25 $Button2.location = New-Object System.Drawing.Point(235,339) $Button2.Font = 'Microsoft Sans Serif,10' $TextBox2 = New-Object system.Windows.Forms.TextBox $TextBox2.multiline = $false $TextBox2.width = 220 $TextBox2.height = 20 $TextBox2.location = New-Object System.Drawing.Point(10,340) $TextBox2.Font = 'Microsoft Sans Serif,10' $OutputBox1 = New-Object system.Windows.Forms.TextBox $OutputBox1.width = 374 $OutputBox1.height = 200 $OutputBox1.multiline = $true $OutputBox1.location = New-Object System.Drawing.Point(10,100) $FormName.controls.AddRange(@($Label1,$TextBox1,$Button1,$Label2,$Button2,$Outputbox1,$Textbox2)) #$Global:data = "" $smtpServer = "" $Button1.Add_Click({Get-MAC }) $Button2.Add_Click({Send }) function Get-MAC { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "ComputerName"($Computer) $obj | Add-Member NoteProperty "IPAddress" ($hostIp) $obj | Add-Member NoteProperty "MacAddress"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "LastReboot"((Get-WmiObject win32_operatingsystem -ComputerName $Computer | select @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}).LastBootUpTime) #$Outputbox1.Text = $obj $OutputBox1.Text = "Computer Name = " + $obj.ComputerName + " IP Address = " + $obj.IPAddress + " MAC Address = " + $obj.MacAddress + " Last Reboot = " + $obj.LastReboot } function Send { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "ComputerName"($Computer) $obj | Add-Member NoteProperty "IPAddress" ($hostIp) $obj | Add-Member NoteProperty "MacAddress"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress #$obj | Add-Member NoteProperty "LastBoots"(get-eventlog system -ComputerName $Computer | where-object {$_.eventid -eq 6005} | select Timegenerated, EntryType, Source, Message -first 10) $obj | Add-Member NoteProperty "LastReboot"((Get-WmiObject win32_operatingsystem -ComputerName $Computer | select @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}).LastBootUpTime) #$Outputbox1.Text = $obj $OutputBox1.Text = "Computer Name = " + $obj.ComputerName + " IP Address = " + $obj.IPAddress + " MAC Address = " + $obj.MacAddress + " Last Reboot = " + $obj.LastReboot $EmailBody = "Computer Name = " + $obj.ComputerName + " IP Address = " + $obj.IPAddress + " MAC Address = " + $obj.MacAddress + " Last Reboot = " + $obj.LastReboot Write-Host $obj Write-Host $EmailBody $EmailAddress = $Textbox2.Text #Send-Mailmessage -smtpServer $smtpServer -from [email protected] -to $EmailAddress -subject "IP / MAC Details for $Computer" -body $EmailBody -bodyasHTML -priority High Write-Host "Button Clicked" } [void]$FormName.ShowDialog()
  9. Hi Tri_94, this seems to do the job - i haven't tested the email side of it as that is a bit awkward in my environment, but the form pulls back all the data - and displays it better. All that need changing was specifiying the computername on the Get-wmi for the reboot, and amending the select arguments after it, to take out the computername (i think). Add-Type -AssemblyName System.Windows.Forms [system.Windows.Forms.Application]::EnableVisualStyles() $FormName = New-Object system.Windows.Forms.Form $FormName.ClientSize = '400,400' $FormName.text = "Form" $FormName.TopMost = $false $Label1 = New-Object system.Windows.Forms.Label $Label1.text = "Please Enter Computer Name" $Label1.AutoSize = $true $Label1.width = 25 $Label1.height = 10 $Label1.location = New-Object System.Drawing.Point(10,20) $Label1.Font = 'Microsoft Sans Serif,10' $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 374 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(10,40) $TextBox1.Font = 'Microsoft Sans Serif,10' $Button1 = New-Object system.Windows.Forms.Button $Button1.text = "Click to Find IP \ Mac Address of Computer" $Button1.width = 374 $Button1.height = 30 $Button1.location = New-Object System.Drawing.Point(10,65) $Button1.Font = 'Microsoft Sans Serif,10' $Label2 = New-Object system.Windows.Forms.Label $Label2.text = "Email Address" $Label2.AutoSize = $true $Label2.width = 25 $Label2.height = 10 $Label2.location = New-Object System.Drawing.Point(11,320) $Label2.Font = 'Microsoft Sans Serif,10' $Button2 = New-Object system.Windows.Forms.Button $Button2.text = "Send As Email" $Button2.width = 150 $Button2.height = 25 $Button2.location = New-Object System.Drawing.Point(235,339) $Button2.Font = 'Microsoft Sans Serif,10' $TextBox2 = New-Object system.Windows.Forms.TextBox $TextBox2.multiline = $false $TextBox2.width = 220 $TextBox2.height = 20 $TextBox2.location = New-Object System.Drawing.Point(10,340) $TextBox2.Font = 'Microsoft Sans Serif,10' $OutputBox1 = New-Object system.Windows.Forms.TextBox $OutputBox1.width = 374 $OutputBox1.height = 200 $OutputBox1.multiline = $true $OutputBox1.location = New-Object System.Drawing.Point(10,100) $FormName.controls.AddRange(@($Label1,$TextBox1,$Button1,$Label2,$Button2,$Outputbox1,$Textbox2)) #$Global:data = "" $smtpServer = "" $Button1.Add_Click({Get-MAC }) $Button2.Add_Click({Send }) function Get-MAC { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "ComputerName"($Computer) $obj | Add-Member NoteProperty "IPAddress" ($hostIp) $obj | Add-Member NoteProperty "MacAddress"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "LastReboot"((Get-WmiObject win32_operatingsystem -ComputerName $Computer | select @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}).LastBootUpTime) #$Outputbox1.Text = $obj $OutputBox1.Text = "Computer Name = " + $obj.ComputerName + " IP Address = " + $obj.IPAddress + " MAC Address = " + $obj.MacAddress + " Last Reboot = " + $obj.LastReboot } function Send { $Computer = $Textbox1.Text if($Computer -eq $null) { $Computer = $env:COMPUTERNAME } $hostIp = [system.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString if($Credential) { $Credential = Get-Credential $Credential $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -Credential $Credential -ComputerName $Computer } else { $wmi = gwmi -Class Win32_NetworkAdapterConfiguration -ComputerName $Computer } $obj = New-Object PSObject $obj | Add-Member NoteProperty "Computer Name"($Computer) $obj | Add-Member NoteProperty "IP Address" ($hostIp) $obj | Add-Member NoteProperty "Mac Address"($wmi | where { $_.IpAddress -eq $hostIp }).MACAddress $obj | Add-Member NoteProperty "Last Reboot"(get-eventlog system | where-object {$_.eventid -eq 6005} | select Timegenerated, EntryType, Source, Message -first 10) $obj | Add-Member NoteProperty "Last Reboot"(Get-WmiObject win32_operatingsystem -ComputerName $Computer | select @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}) #$Outputbox1.Text = $obj $OutputBox1.Text = "Computer Name = " + $obj.ComputerName + " IP Address = " + $obj.IPAddress + " MAC Address = " + $obj.MacAddress + " Last Reboot = " + $obj.LastReboot $EmailBody = "Computer Name = " + $obj.ComputerName + " IP Address = " + $obj.IPAddress + " MAC Address = " + $obj.MacAddress + " Last Reboot = " + $obj.LastReboot #Write-Output $obj $EmailAddress = $Textbox2.Text Send-Mailmessage -smtpServer $smtpServer -from [email protected] -to $EmailAddress -subject "IP / MAC Details for $Computer" -body $EmailBody -bodyasHTML -priority High Write-Host "Button Clicked" } [void]$FormName.ShowDialog()
  10. I was asked the same recently, so if necessary comms could go out to the affected students. From what I can see, and what a quick google resulted in - there is unfortunately no way to tell which students took up the free offer ....
  11. I think you've got the foreach bit wrong ... i think it should be: foreach ($entry in $data) { MsiExec.exe /X $entry.pschildname } As $data is the array containing all the uninstall items like "Sophos" etc., and $entry is the inidividual item in the array you want to act on at the time.
  12. Thats similar to what I can see in our Adobe console, only we've got 36/1 machines used - and it seems to be working ok so far.
  13. The last time we used MS support several years ago we had to pay £250 as well - although we claimed it back given that after about a week we solved the problem ourselves off the back of some forum posts rather than the MS rep being helpful..
  14. Epic Games have got their sale going on at the minute. GTA 5 free this week ...
  15. Maybe the multiple pipes to other actions / functions is messing with the final move-item as it may not be receiving whats expected. Try splitting the final line up so it runs once to carry out the export-csv, and then it runs again to carry out the move-item ?
  16. Not sure how celebrity it is, but when I was working in the local we used to get Steve Halliwell (Zack from Emmerdale) coming in quite a lot - and we used to be able to have quite a chat with him.
  17. We seem to have solved it by adding a second reg key to our GPO... [TABLE=class: info] [TR] [TD]Action[/TD] [TD]Update[/TD] [/TR] [/TABLE] Properties [TABLE=class: subtable] [TR] [TD]Hive[/TD] [TD]HKEY_CURRENT_USER[/TD] [/TR] [TR] [TD]Key path[/TD] [TD]SOFTWARE\Policies\Microsoft\Office\16.0\Teams[/TD] [/TR] [TR] [TD]Value name[/TD] [TD]PreventFirstLaunchAfterInstall[/TD] [/TR] [TR] [TD]Value type[/TD] [TD]REG_DWORD[/TD] [/TR] [TR] [TD]Value data[/TD] [TD]0x1 (1)[/TD] [/TR] [/TABLE] Also, as a side note ... the reg key you've already got is in HKCU, but you're doing it in the computer config section ... doesn't it need to be in the user section (thats where we do it, using GPO loopback processing to apply user settings to a computer targeted GPO) ?
  18. try using: icacls "C:\Test\1" --% /grant:r [email protected]:(OI)(CI)M /T the --% tells powershell to interpret the rest of the line as a basic text string, and not to try and process any of it as cmdlets. This is how we use icacls in powershell scripts when we have to.
  19. This week on the Epic games store, you can get the Batman:Arkham collection and the Lego Batman trilogy free .... Batman: Arkham Collection - https://www.epicgames.com/store/en-US/bundles/batman-arkham-collection Lego Batman Trilogy - https://www.epicgames.com/store/en-US/bundles/lego-batman-trilogy
  20. Skype for business stops working properly if more than one person is logged in.
  21. I though that if its just a DP, it doesn't need a server OS with the newer versions of SCCM (even if you want to be able to PXE boot, I've read that it can be done without WDS now) ... so drivers might not be an issue. Much like Arthur, we use NUCs for digital signage and they are all running 24/7 and we haven't had any failures yet (we must have at least 40 - 50 of them, some of which must be getting on for 5 yrs old)
  22. Look at implementing MS LAPS to control local admin account passwords ?
  23. I did that in a similar method to adding the langugage features - got the .cab file from the features iso, added it to a package in sccm and ran a bit of powershell to add it : # Specify location where the script is running from $currentLocation = Split-Path -Parent $MyInvocation.MyCommand.Path; # enable the feature, using the source files in the current folder, not running away to MS update Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -Source $currentLocation -LimitAccess -All
  24. I've added the steps after it installs and configures the SCCM client, so that it runs whilst booted into Windows and not in WinPE ...
  25. I think so, yeah. I can't find the bookmark I used at the minute to work out how / why mine might be named differently. If need be I can throw what I've got up on the web and make it available for you.
×
×
  • Create New...