Reverting to the original prompt in PowerShell Console - function

In PowerShell console window the initial prompt is
C:\users\username
I could customize the prompt with the below:
function Prompt { "PS: "}
The prompt now becomes
PS:
Without making change to the C:\Users\user\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 I intend to revert to the original prompt.
How to go about it?

From the about_Prompt help file:
In Windows PowerShell 3.0, the built-in prompt function is:
function prompt
{
"PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}

Related

cant compile raylib for web

I have been trying to compile my raylib game to web (following this tutorial https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5) ) and i got stuck on this part:
Before compiling raylib, make sure all paths to emscripten (EMSDK_PATH) and tools are correctly configured on
C:/raylib/raylib/src/Makefile, you must verify these lines.
To compile raylib source code, just execute Notepad++ script: raylib_makefile and SET PLATFORM=PLATFORM_WEB.
To do this, start up Notepad++ for raylib, open the raylib.h file, press F6, choose raylib_makefile, verify that
in the script SET PLATFORM=PLATFORM_WEB, then click OK to run the script. That script just calls the following make
line (in case you're are working on a custom environment):
make PLATFORM=PLATFORM_WEB -B
When i open C:\raylib\raylib\src\raylib.h in notepad++ and press F6 nothing happens and when i try to call make PLATFORM=PLATFORM_WEB -B in the powershell it says
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ make PLATFORM=PLATFORM_WEB -B
+ ~~~~
+ CategoryInfo : ObjectNotFound: (make:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
please help

Mysql database restoring with fab and curses in django

#hosts(['localhost'])
def start():
import curses
screen = curses.initscr()
backup_file = db_backup.sql
local("mysql -u %s -p %s < " % (
db_username,db_name) + backup_file)
now I run this with fab start
it asks for a password, after I entered the password the screen is not responding.
Can anyone know what's happening here? if I remove curses it is working fine.
The local command is doing the prompt for the password. That expects that the terminal modes are set normally, so that if you press Enter (which sends a ^M) it is mapped into a newline (^J).
When you initialized curses using curses.initscr, that changes the terminal modes so that the mapping is not done. The curses library does its own mapping when you call getch.
If you press controlJ rather than Enter, that should appease the password prompt in the local command.
Since your example is not using curses (perhaps it does later) you can either omit it, or move the initialization down to the place where you need to use it.
In any case, you probably cannot make the local command use a password prompt in the script via curses (without assuming and relying upon special devices).
By suspending the curses, it will return to the terminal. where we can complete the restore database task.

How to close the console in the geth console

In Ethereum I opened the javascript console with "geth console" but I can not close it anymore.
I have tried ctrl-c, but it does not work.
Just type exiton the geth console
Ctrl + c is the shortcut to clear the input prompt.Ctrl + d will exit the console when the input line is clear.
Alternatively, you can type the command exit

Run Net Share command in powershell script

I try to share a folder in powershell with net share command, i can't use group or user name for share permission because this script will be used on the systems with different os languages, for this reason i use group/user SID to set up share permissions.
Here is my script, my function work great outside of command. But my function dont work in "NET SHARE" cmd.
function Get-GroupName {
param ($SID)
$objSID = New-Object System.Security.Principal.SecurityIdentifier($sid)
$objUser = $objSID.Translate([System.Security.Principal.NTAccount])
$objUser.Value
}
# Share Folder + Set Share Permission SID Based
cmd /c net share MSI=C:\MSI /GRANT:(Get-GroupName -SID 'S-1-1-0'),READ
This will work:
cmd /c $( "net share MSI=C:\MSI /GRANT:""$(Get-GroupName -SID 'S-1-1-0')"",READ" )
But if you're on Windows 8 or newer, Windows Server 2012 or newer you can use the Set-SmbShare and Grant-SmbShareAccess cmdlets instead:
http://technet.microsoft.com/en-us/library/jj635727
http://technet.microsoft.com/en-us/library/jj635705

Powershell script works in Powershell but fails in Task Scheduler

I have a PowerShell script that sends an email via SMTP. The script runs fine inside Powershell ISE, but fails in Task Scheduler. I am on Windows Server 2012. I have other Powershell scripts that I run on this server using the exact same setup, but those scripts do not send an email. The return code I see in Task Scheduler is (0xFFFD0000) and I cannot find any information on this. I have the task set to run with highest privileges and I have checked that the executionpolicy is RemoteSigned. Anybody run into this before?
Here is the command in the task:
powershell -f "c:\scripts\EmailTest.ps1"
Here is the script:
$EmailFrom = "user#domain.com"
$EmailTo = "someone#somewhere.com"
$Subject = "Email Subject"
$Body = #"
Person,
Some message here
Thanks,
User
"#
$SMTPServer = "smtp.domain.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("user#domain.com", "password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Update:
I was able to resolve the issue. Apparently I had an additional line in the script that was commented out. I'm not sure why this would cause an error but once I removed that commented out line it ran fine in Task Scheduler. the comment looked like this and was just below the other $EmailTo declaration in the above script:
#$EmailTo = "someone#somewhere.com"
I found another possible issue while looking at a similar problem. I was unable to execute a PowerShell script as a Task Scheduler action, even though the script ran correctly when logged into Windows as the target user and running within PowerShell.
Task Scheduler would consistently display the 0xFFFD0000 error when I nominated the script in the task's action arguments using what I believed to be normal PowerShell quoting rules:
-ExecutionPolicy Bypass -File 'D:\full path\to\script.ps1'
PowerShell acquiesced and Task Scheduler fired off the task immediately and without issue when I changed the quotes I used from single to double:
-ExecutionPolicy Bypass -File "D:\full path\to\script.ps1"
Dropping to a command prompt and executing the full command immediately revealed the problem:
D:\>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File 'D:\full path\to\script.ps1'
Processing -File ''D:\full path\to' failed: The given path's format is not supported. Specify a valid path for the -File parameter.
Notice the strange use of two single quotes before the path and one single quote after.
The moral of the story: When feeding the full path of a script to PowerShell as a command line parameter, use double quotes!
I was receiving the same error and ultimately I had a different issue - the optional start in directory setting wasn't applied.
Essentially, I was running a .bat file - c:\tasks\process.bat
This .bat file referenced multiple ps1 scripts that were in the tasks directory and the references were just by file name (not the full directory). On the action tab in task scheduler, there is a Start in (optional) field that I had not populated. Setting it to c:\tasks allowed the references to function properly.
First of all you have to check "ExecutionPolicy" configured on your machine. to do so, check default values by following this link https://technet.microsoft.com/en-us/library/hh847748.aspx
I fixed my probleme by using this command:
On "Add arguments" option I put:
"-Executionpolicy Bypass -command "& 'T:\deleteOldMessages.ps1' "
and