Powershell: Export List of apps - list

I wanted a hands off approach to get a list of all the applications installed on a system.
A search brought me to many websites that utilized Get-ItemProperty like on this page here
I quickly found that I could export the list to txt file for easy access at a later time.
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\Users\username\Documents\InstalledPrograms-PS.txt
*username is a place holder
What I found, however, is that I could run this when pasting it directly into powershell, but when placing this into a script, it would crash or not run at all.
I'm assuming I'm missing something and a straight copy and paste will not work.
Any help would be appreciated.
NOTE: I'm sure someone is bound to recommend WMIC, but this does not seem to list all the apps.
Update:
Seems that within my script
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
on its own works just fine. It's when the formatting happens that it crashes.
Solution:
For anyone looking to get an easy and quick way to get a list of all applications, including microsoft store ones, here's what I did. I just have them export to a .txt file to keep for later.
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table > c:\applist.txt
Microsoft Store Apps
Get-AppxPackage | Select Name, PackageFullName |Format-Table -AutoSize > c:\microsoftlist.txt

It worked for me, although emacs said the '-' before AutoSize was a foreign character. \226
It may be unicode en dash, 8211 decimal: https://www.fileformat.info/info/unicode/char/2013/index.htm A regular dash would be 45.
[int][char]'–'
8211
By the way, there's also get-package to list installed applications.

Related

bulk change sas project code nodes directory

I have a SAS Project(SAS Enterprise Guide version 7.15) and all the sas code nodes are currently saved on directory location,
'C:\Users\SAS\Prod\SASCode'. I am taking a backup of this project to the Dev area and I would like to save the sas code nodes to the following Dev location 'C:\Users\SAS\Prod\SASCode'. Is there a way I can bulk change the location of all this sas code nodes to the above Dev location instead of going into individual sas codes nodes and change it one by one which is of course very time consuming process.
Enterprise Guide project files are really a collection of files within a zip archive that has a file extension .egp instead of .zip.
Suppose your code nodes are shortcuts to files in the operating system, in a single folder, and you want to change where those files are located. The targets of the shortcuts are stored in the egp file in a contained file project.xml as project metadata. project.xml is a UTF-16 encoded file and the shortcuts are xml data within a <FullPath> node. The xml file is very systematic and can be text processed with out needing to do a full xml parsing. The goal is to replace the old path with the new path for data in FullPath nodes.
Powershell is a very potent tool for Windows scripting and can be used to tear apart the project file, modify the paths and reassemble the pieces back into an .egp project file.
Consider this powershell script:
The code nodes for the original project were shortcuts to files in C:\Zeus\sources. Suppose those sources were copied or moved to C:\Olympus\sources. The code nodes of an updated EG project have to be modified to point to the new location.
$egpIn = 'C:\Q1\Zeus.egp'
$egpOut = 'C:\Q2\ZeusModified.egp'
$oldPath = 'C:\Zeus\sources'
$newPath = 'C:\Olympus\sources'
Copy-Item "$oldPath\*.sas" -Destination $newPath
$oldLandmark = [regex]::Escape('<FullPath>' + $oldPath)
$newLandmark = '<FullPath>' + $newPath
$workingFolder =
[System.IO.Path]::Combine(
[System.IO.Path]::GetTempPath(),
[System.IO.Path]::GetRandomFilename()
)
[System.IO.Compression.ZipFile]::ExtractToDirectory($egpIn, $workingFolder)
Get-ChildItem $workingFolder *.xml -recurse |
Foreach-Object {
$fileContent = ($_ | Get-Content -Encoding Unicode)
$fileContent = $fileContent -replace $oldLandmark, $newLandmark
[IO.File]::WriteAllText($_.FullName, ($fileContent -join "`r`n"), [System.Text.Encoding]::Unicode)
}
if (Test-Path $egpOut)
{
Remove-Item $egpOut
}
[System.IO.Compression.ZipFile]::CreateFromDirectory($workingFolder,$egpOut)
Remove-Item $workingFolder -Recurse
Should be possible, since EG-Project are basicly ZIP-files containing the various elements.
One of these Elements is the file "project.xml" wich contains the references to external code-files.
Replacing this references with the new location should solve your problem.

How do I get a list of Search Templates in Elasticsearch 5.x?

It appears the .scripts index no longer exists in this version, so I cannot just do http:\\<elasticsearchserver>:9200\.scripts\_search.
According to the docs, scripts should be in the config\scripts directory, but the \etc\elasticsearch\scripts folder is empty in my environment. I have one template created at the moment, so it seems to me that something should be in there.
I found that when you add a Search Template via the API, it is stored in the cluster state, and you can get the list in /_cluster/state under "metadata"->"stored_scripts".
For me, the "code" under some of our templates were massive, obscuring the names of the templates, which is all I wanted. This snippet will parse just the template names using the jq utility: curl 'localhost:9200/_cluster/state' | jq '.metadata.stored_scripts | keys'

Is there any way to have the line comment shortcut add a space after // in WebStorm?

When using the shortcut for commenting a line of code (command / on a Mac), the code line gets a // added in front of it. (Pointing out the obvious for topic clarification).
Stylistically I would like to add a space between the // and the start of some code that I'm commenting out. i.e. make the comment leader when added // function foo() { rather than //function foo() { which is the default.
What I can't find is how to change this setting in JetBrains WebStorm (I've already tried trolling their website and the preferences etc with no success) - I've also run many searches (my google-foo is terrible!) but have yet to find how to change this setting.
Anybody know how (or if?) this setting can be changed?
As far as I'm aware it's not possible.
https://youtrack.jetbrains.com/issue/IDEA-141701 -- watch this ticket (star/vote/comment) to get notified on progress.
UPDATE (20th April, 2016)
It's now implemented and available as of 2016.1 version.
Settings/Preferences | Code Style -- It was implemented for these languages (not sure about any other):
Java -- Java | Code Generation | Comment Code
JavaScript/TypeScript -- JavaScript | Other | Comment Code
PHP -- PHP | Other | Comment Code
I highlight the code that I want to comment out and use tab to indent, and then cmd + / to add "//"

How can I change the template comment on new file creation?

When I create a new javascript file, a template like comment is added at the top of the file that looks like this:
/**
* Created by User on 2015-03-29.
*/
I would like to modify this template, but I cannot for the life of me figure out how.
In the settings page, I have tried searching for 'IDE settings', 'File and Coding Template' (as it would be in PHPStorm, I believe), 'Copyright' (as in IntelliJ), 'header', 'template', 'comment' and different combinations of those terms. But none of these terms result in anything relevant. And searching on google is difficult, because most links take you to PHPStorm or IntelliJ help docs.
Maybe my google-fu is off today...
Settings (Preferences on Mac) | Editor | File and Code Templates | Templates -- you need JavaScript File entry.
And searching on google is difficult, because most links take you to PHPStorm or IntelliJ help docs.
Well ... PhpStorm = WebStorm + PHP + Databases -- in terms of settings it is exactly the same... (comparable builds of course)
P.S.
In previous versions (WebStorm v8, PhpStorm v8.0.1 and older, IntelliJ v13) all Settings were in single column but separated in 2 groups: "Project Settings" on top and then "IDE Settings" on the bottom of the list. In current versions all settings are mixed together using collapsible tree structure and you have to look for special icon next to the settings section name -- it will tell if you this is an IDE wide setting or project specific.

Django view of filenames in PyDev

Quick question: sometimes, when I have a similar file from two or more apps open, PyDev shortens the tab name to something like "views.py | app1" and "views.py | app2". Sometimes, it just gives me the whole filepath. Is there a way to force the first view?